Datagrid
Hi,
I need to display calculation values on the datagrid but the problem is how do I control the datagrid if data in S1 field is =0
If its 0 this msg will come out :->divide by zero error encountered
Sub BindGrid()
BindDataSet()
DataGrid1.Visible = True
DataGrid1.DataSource = dv
With DataGrid1
Try
DataGrid1.DataBind()
Catch
.CurrentPageIndex = 0
DataGrid1.DataBind()
End Try
End With
End Sub
Sub BindDataSet()
Dim Area_sf, PSF, L_Area, Price As Double
objConn = New SqlConnection(ConfigurationSettings.AppSettings("c onnVIOS"))
strSql = "SELECT *, L_AREA / 0.0929AS Area_sf ,PRICE/(L_AREA / 0.0929) * S2/S1 AS PSF FROM VSALES2"
sda = New SqlDataAdapter(strSql, objConn)
ds = New DataSet
sda.Fill(ds, "Sales")
dt = ds.Tables("Sales")
dv = New DataView(dt)
lblAyat.Text = "Record Found - " & dv.Count
objConn.Close()
End Sub
Please help and thanks in advance.
|