Hi All,
I see the following on MSDN:
The DataGrid control supports several events. One of them, the ItemCreated
event, gives you a way to customize the item-creation process. The
ItemDataBound event also gives you the ability to customize the DataGrid
items, but after the data is available for inspection. For example, if you
were using the DataGrid control to display a to-do list, you could display
overdue items in red text, completed items in black text, and other tasks in
green text.
I nearly want to do the same thing,
but in the event ,I can't access the value I wanted with the commented
line, but this statemetn works well on the Item Updat event.
public void MyDataGrid_DataBound(Object sender, DataGridItemEventArgs e)
{
//string s1
=((System.Web.UI.WebControls.TextBox)e.Item.Cells[7].FindControl("edit_Sate"
)).Text;
if(s1=="UT")
e.Item.BackColor =Color.Green ;
}
I wonder how to access the one of the cell's bounded value of the just added
row.
Thanks!
Arvind P Rangan - 25 Feb 2004 11:58 GMT
Hi ChunMing,
Have you tried doing this in DAtaGrid_ItemCreate
under this
try in
if e.Item.ItemType = ListItemType.AlternatingItem Or e.Item.ItemType =
ListItemType.Item
=((System.Web.UI.WebControls.TextBox)e.Item.Cells[7].FindControl("edit_Sate"
)).Text;
if(s1=="UT")
e.Item.BackColor =Color.Green ;
your code to change the color.
this option is for listing only not in edit mode.
Check it out.
Same syntax under this option.
> Hi All,
> I see the following on MSDN:
[quoted text clipped - 14 lines]
> {
> //string s1
=((System.Web.UI.WebControls.TextBox)e.Item.Cells[7].FindControl("edit_Sate"
> )).Text;
> if(s1=="UT")
[quoted text clipped - 5 lines]
>
> Thanks!
Volkan Karabo?a - 26 Feb 2004 07:28 GMT
checkout the message which subject's is "changing row color depending on a
cell value"
at this group sended 20/02/2004
I think it helps you...
> Hi All,
> I see the following on MSDN:
[quoted text clipped - 14 lines]
> {
> //string s1
=((System.Web.UI.WebControls.TextBox)e.Item.Cells[7].FindControl("edit_Sate"
> )).Text;
> if(s1=="UT")
[quoted text clipped - 5 lines]
>
> Thanks!