我在我的 GridView 中有 Column(Validate),该列包含两个值“v”或“notv”我想从 myGridview 获取值“ v ”并将其更改为“ VALIDATE ”,另一个“ notv ”更改为“不验证'..我已经尝试GridView1.Rows(i).Cells(10).Text
但是当我的 Gridview 显示时没有任何改变。
这是我的代码:
当我单击按钮时,会显示 GridView:
<asp:GridView ID="GridView1" runat="server" CssClass="table" GridLines="None">
</asp:GridView>
'页面.aspx.vb
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
感谢您的时间!