我想通過gridview中的行和文本中的行如果該行匹配來遍歷數據集的值。gridview PageIndexChanging問題
下面的代碼正常工作,但無論何時我通過PageIndexChanging
更改頁面並且此功能再次運行時,着色都不起作用。如果有一個匹配,它仍然通過gridview循環,但沒有顯示效果。
--variable initialization class instantiation--
--code to connect to db here--
mySQLCommand.CommandText = "SELECT ..."
mySQLAdapter = New SqlDataAdapter(mySQLCommand)
mySQLAdapter.Fill(myDataset)
Me.MainPageGridView.DataSource = myDataset
Me.MainPageGridView.DataBind()
mySQLCommand.CommandText = "SELECT ... The ID's to be matched"
mySQLAdapter = New SqlDataAdapter(mySQLCommand)
mySQLAdapter.Fill(myDatasetNew)
Me.MainPageGridView.DataSource = myDatasetNew
For Each dataRow In myDataset.Tables(0).Rows
thisID = dataRow("ID").ToString
For Each gvRow In Me.MainPageGridView.Rows
If gvRow.Cells(2).Text = thisID Then
For column = 0 To 14 Step 1
gvRow.Cells(column).ForeColor = Drawing.Color.RosyBrown
Next
Exit For
End If
Next
Next
你爲什麼要結合兩個數據集,以相同的網格? – Waqas