Change font row color from conditions on a datagrid
-
hi. i'd like to ask how can i change the font color of a specific row on a datagrid based from conditions? ex: if it sees "CRITICAL" anywhere on the row, it will change the entire row's font color to red and if it sees "WARNING" to green.. etc... pls help me how can i do that? here's my code: Sub Page_Load(Sender As Object, E As EventArgs) 'some codes MyCommand = New SqlDataAdapter("SELECT ReceivedTime, SenderName, Subject FROM NewMessages where Subject not like '%alertlog%' and Subject like '%ars%' ", MyConnection) DS = new DataSet() MyCommand.Fill(ds, "NewMessages") MyDataGrid.DataSource=ds.Tables("NewMessages").DefaultView MyDataGrid.DataBind()
MARS
-
hi. i'd like to ask how can i change the font color of a specific row on a datagrid based from conditions? ex: if it sees "CRITICAL" anywhere on the row, it will change the entire row's font color to red and if it sees "WARNING" to green.. etc... pls help me how can i do that? here's my code: Sub Page_Load(Sender As Object, E As EventArgs) 'some codes MyCommand = New SqlDataAdapter("SELECT ReceivedTime, SenderName, Subject FROM NewMessages where Subject not like '%alertlog%' and Subject like '%ars%' ", MyConnection) DS = new DataSet() MyCommand.Fill(ds, "NewMessages") MyDataGrid.DataSource=ds.Tables("NewMessages").DefaultView MyDataGrid.DataBind()
MARS
Handle an onitemdatabound event, then you can get your row and look through it/change it's properties. Christian Graus - Microsoft MVP - C++
-
Handle an onitemdatabound event, then you can get your row and look through it/change it's properties. Christian Graus - Microsoft MVP - C++
ohh..how can i do that? can u give an example? i'm really puzzled..thanks..:confused:
-
ohh..how can i do that? can u give an example? i'm really puzzled..thanks..:confused:
In the aspx: Then in your page protected void OnItemDataBound(object sender, DataGridItemEventArgs e) { // e.Item is the row in question, then you can cast that to a more defined type ( TableRow probably ) and search through it/set properties/etc. // Look up OnItemDataBound in MSDN for more examples } Christian Graus - Microsoft MVP - C++
-
In the aspx: Then in your page protected void OnItemDataBound(object sender, DataGridItemEventArgs e) { // e.Item is the row in question, then you can cast that to a more defined type ( TableRow probably ) and search through it/set properties/etc. // Look up OnItemDataBound in MSDN for more examples } Christian Graus - Microsoft MVP - C++
it's done what about adding tooltip when a user moves his mouse to a record? it will show up something from the same row from the database?
-
it's done what about adding tooltip when a user moves his mouse to a record? it will show up something from the same row from the database?
Controls have a tooltip property. Christian Graus - Microsoft MVP - C++