Get column value from a gridview using VB.net
I have in my GridView the Column(Validate), this column in contains two
values 'v' or 'notv' I want to get the value 'v' from myGridview and
change it to 'VALIDATE' and the other 'notv' to 'Not validate'.. I have
Tried GridView1.Rows(i).Cells(10).Text But nothing has been changed when
my Gridview is displayed.
Here is my code:
The GridView is displyed whan I click on Button:
cmd.Connection = cx
cmd.CommandText = "select .., validate from table"
da = New SqlDataAdapter(cmd)
da.Fill(dt)
GridView1.DataSource = dt
GridView1.DataBind()
For i = 0 To GridView1.Rows.Count - 1
GridView1.Rows(i).Cells(0).ForeColor = System.Drawing.Color.Blue
If GridView1.Rows(i).Cells(10).Text = "v" Then
GridView1.Rows(i).Cells(10).Text = "VALIDATE"
GridView1.Rows(i).Cells(10).ForeColor =
System.Drawing.Color.Green
ElseIf GridView1.Rows(i).Cells(10).Text = "Notv" Then
GridView1.Rows(i).Cells(10).Text = "Not VALIDATE"
GridView1.Rows(i).Cells(10).ForeColor =
System.Drawing.Color.Red
End If
Next
Thank you for your Time!
No comments:
Post a Comment