Here i m comparing GridView2.Rows(i).Cells(3).Text with reader(0)
but i m getting Error
Public Sub checkpipno()
Dim i As Integer
For i = 0 To GridView1.Rows.Count - 1
Dim vr As String
vr = GridView2.Rows(i).Cells(5).Text
Dim village As String = GridView2.Rows(i).Cells(3).Text
Dim con As New SqlConnection(connStr)
con.Open()
Dim sql As String = "SELECT pipno,pipcode1 FROM PIP_Entry WHERE Rpt_Unit = '" & village & "' "
Dim cmd As New SqlCommand(sql, con)
Dim reader As SqlDataReader = cmd.ExecuteReader()
While reader.Read()
If vr = reader(0).ToString() Then
GridView2.Rows(i).Cells(14).Text = reader(1).ToString()
GridView2.Rows(i).Cells(14).BackColor = System.Drawing.Color.FromName("Green")
GridView2.Rows(i).Cells(15).Text = "Done"
GridView2.Rows(i).Cells(15).BackColor = System.Drawing.Color.FromName("Green")
End If
End While
reader.Close()
con.Close()
Next
End Sub
The Above Code i have used to compare Grid view row with other table value i.e., in reader(0). But here i m getting error in VB.NET
That is 'Rows' is not a member of 'System.Web.UI.WebControls.DataGrid'.
Post Solution for this Post
SenthilkumarPosted Mar 25, 2012, 11:54 PM
There is some difference in GridView and DataGrid.
When you use the DataGrid it is referenced by the ItemCollection.
gridview1_ItemCommand
gridview1_ItemDataBound
e.Item.ItemType
But the same time if you use the GridView control then
gridview1_RowCommand
gridview1_RowDataBound
e.Row.RowType
Hope this will help you understand.
VulpesPosted Mar 25, 2012, 10:12 AM
This doesn't have a Rows collection but instead has an Items collection.
So, in the above code, I'd simply replace Rows with Items and see whether it will build.
brunda kPosted Mar 25, 2012, 9:49 AM