2012-08-30 35 views
1

我有一個GridView顯示來自sql server的結果,所有的值都應該跟在先前的值上,例如, 3373必須在3372之前。只要值不符合先前的值,我需要在gridview上着色該行。有時候這些值會丟失,所以我需要確定一個值是否丟失。基於前一行的asp.net vb gridview coulours

回答

1

您可以使用OnRowDataBound事件來存儲上一個值並進行比較。這樣的事情:

Private _lastRowValue As Integer = -1 

Protected Sub OnGridViewRowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs) 
    If e.Row.RowType = DataControlRowType.DataRow Then 
     If _lastRowValue <> -1 Then 
      ' read current row value, compare and then format, e.g. like this 
      e.Row.Cells(1).Text = "<i>" + e.Row.Cells(1).Text + "</i>" 
     End If 
     _lastRowValue = ... ' read value from cell 
    End If 
End Sub 
+0

感謝您的。是否有可能在VB中發送響應?我對此很新穎。 – user1635791

+0

您總是可以使用像http://www.dotnetspider.com/convert/CSharp-To-Vb.aspx這樣的轉換器。否則,添加VB.NET標記(就像我爲你做的那樣)。 – slfan

相關問題