Click here to Skip to main content
15,867,895 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
HI,
In my gridview all fields in black.
I have to display in that actual and estimated cost of products.
if there at all actual cost cross the estimated cost. I have to display that actual cost color in red.

I don't have any idea about this help me please.

Thanks,
Posted
Updated 10-Dec-10 19:07pm
v4
Comments
Abdul Quader Mamun 11-Dec-10 1:07am    
Grammar & Spelling check.

Thank you for your question. Use Item Data Bound for this. Like bellow code.

XML
<asp:DataGrid id="ItemsGrid" runat="server"
     BorderColor="black"
     BorderWidth="1"
     CellPadding="3"
     ShowFooter="true"
     OnItemDataBound="Item_Bound"
   <HeaderStyle BackColor="#00aaaa">
   </HeaderStyle>
   <FooterStyle BackColor="#00aaaa">
   </FooterStyle>
</asp:DataGrid>




C#
void Item_Bound(Object sender, DataGridItemEventArgs e)
{
   //Label1.Text = Label1.Text + " " + e.Item.ItemIndex;
   // Your code here for Make Red to Product Cost Cell;

}



Thanks,
Mamun
 
Share this answer
 
Comments
Brij 11-Dec-10 1:43am    
Question is for Gridview. Gridview has no event as Item_Bound
Abdul Quader Mamun 11-Dec-10 1:54am    
item_Bound is not a event. It is method that you need to bind to OnItemDataBound of GridView. like OnItemDataBound="Item_Bound"
There is is event called Rowdatabound of gridview. That is fired for each row.Here you can access each cell of row and can change the color or anything as per your requirement.
To know details of it Have a look
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900