i want to compare between the cell value with the value(parameter) in database.

as example, if my cellvalue value is 3 and my paramater(a) in my database is 5 it will be like this
if cellvalue<a then
(some code)
end if


the problem is i don't know the exact data type. the reason i need to use data type is because my data is dynamic.

here is my code:

protected SubGridView1_RowDataBound(ByVal Sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound 
  
con = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;DataSource=C:\Users\me\Documents\Visual Studio 2005\WebSites\CSG\CSG1.mdb") 
con.Open() 
detReport = New OleDbDataAdapter("Select * From parameterData WHERE (alert_ID = 'CR') AND (alert_type = alert_ID)", con) 
Dim a As Int32 
DetReport.Equals(a) 
  
if e.Row.RowType = DataControlRowType.DataRow Then
Dim CellValue As Decimal = convert.ToDecimal(e.Row.cells(4).text) 
if CellValue < a then 
e.Row.Cells(4).BackColor = Drawing.Color.Red 
End if 
End if 
  
con.close() 
  
End Sub

i hope that you all can help me. thanks in advance :)

In order to determine the datatype, you first need to determine the content type.
If the content type is String, then you need to find out if it's strictly numeric.
And if that is the case, then the content can be cast as Integer/Double/Decimal, or else you have to do something else with the information.

When that is done, you can perform your comparison.

Dim cellData As String = e.Row.Cells(4).Text
For Each c As Char In cellData
   If Not Char.IsNumeric(c) Then
      'The cell contains text, so do something about it

      'Jump out of the method, because you can't compare text ("abc") with numbers (123)
      Exit Sub
   End If
Next

'Then continue with your coding
Dim CellValue As Decimal = Convert.ToDecimal(cellData)
If CellValue < CDec(a) Then
   e.Rows.Cells(4).BackColor = Drawing.Color.Red
End If
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.