Click here to Skip to main content
14,734,126 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to change GridView selected row color LightGray to #F1F1F1 .

I do like this. Please suggest me over currect method.

 GridViewRow gvr = (GridViewRow)(((LinkButton)e.CommandSource).NamingContainer);
 int RowIndex = gvr.RowIndex;
 Grd_ProductSubCategory.Rows[RowIndex].Cells[0].BackColor = System.Drawing.Color.#F1F1F1 (not taken as it is)

but accept :   System.Drawing.Color.LightGray;

But I want to change it as >>> System.Drawing.Color.#F1F1F1

1 solution

Try this

Grd_ProductSubCategory.Rows[RowIndex].Cells[0].BackColor = System.Drawing.ColorTranslator.FormHtml("#F1F1F1);"

Hope this works for you.
mimtiyaz 11-Mar-13 7:47am
What error exactly you are getting ?
mimtiyaz 11-Mar-13 7:48am
Oops I missed one double quotation in the syntax... ("#F1F1F1);"
try to make it ("#F1F1F1");
Mas11 11-Mar-13 7:49am
Thanks Imtiyaz it works ! NIce job bro.
5* for it.
mimtiyaz 11-Mar-13 7:50am
My Pleasure.

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