|
| ||||||||||
| Tags: change cell color, change row color, gridview color, gridview control |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| Change Color of a cell of Gridview control in Asp.Net
I want to change the cell color in gridview in my asp.net project. but i don't know how to change the color in runtime. If you have any idea about this please help me. |
|
#2
| ||||
| ||||
| Re: Change Color of a cell of Gridview control in Asp.Net
In RowDataBound event of GridView, you can do that. use this code, Code: protected void GridView2_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Cells[0].BackColor = System.Drawing.Color.Gray;
}
} Hope this helps you. |
|
#3
| ||||
| ||||
| Re: Change Color of a cell of Gridview control in Asp.Net
You can use a template or you can handle the rowdatabound event. if you handle the event, you can simply change the background of the cell with code similar to this one: void Handle( object sender, GriViewRowEventArgs args ) { args.Row.Cells[put the position of the cell here].BackColor = your color here; } |
|
#4
| |||
| |||
| Re: Change Color of a cell of Gridview control in Asp.Net
You can refer to http://msdn.microsoft.com/en-us/library/aa479342.aspx for more information about gridview control. |
|
#5
| ||||
| ||||
| Re: Change Color of a cell of Gridview control in Asp.Net
If you want to change the color of selected row or cell then, try the below one... Code: Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.SelectedIndexChanged
GridView1.SelectedRow.Cells(4).BackColor = Drawing.Color.Red
End Sub |
|
#6
| |||
| |||
| Re: Change Color of a cell of Gridview control in Asp.Net
Useful Materials. They works for me. Thanks a lot ![]() |
![]() |
|
| Thread Tools | Search this Thread |
| |
Similar Threads for: "Change Color of a cell of Gridview control in Asp.Net" | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Is there any option to change the color of friend/foe to help color blinds play Birds of Steel? | I M Perfect | Video Games | 3 | 18-03-2012 07:33 PM |
| Does it is possible to have color shading in a Count if cell | Rounder1 | MS Office Support | 2 | 16-02-2012 05:37 PM |
| How to change cell color in excel based on text input | Chini mao | Windows Software | 2 | 06-01-2012 08:19 PM |
| How to put background color for html cell | Preetish | Software Development | 3 | 07-08-2009 03:32 PM |
| Excel 2000 - Change Default Cell Fill Color | Cris Han | MS Office Support | 2 | 20-02-2008 08:29 PM |