Click here to Skip to main content
15,886,518 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am binding gridview to datatable and id displaying in textbox inside gridview. If id containg any character or special character that time textbox backcolor should be in red color. I am not able to change the color of textbox please help me.
Posted
Comments
IpsitaMishra 29-May-13 7:10am    
Can you please provide your code ,how you are binding the grid.
Orcun Iyigun 29-May-13 8:25am    
Look more into gridview's RowDataBound event. You can easily do it there. In that event check if the value has a special character and if so change the back color. SHould not be that hard..

1 solution

procted void grd_onrowdatabound(object sender, gridviewroweventargs e)
{
IF(e.row.rowtype==DataControlRowType.DataRow)
{
textbox txtpin=e.row.findcontrol("txtpin") as textbox;
if(txtpin.text=="condition")
{
txtpin.backcolor=system.drawing.color.red;
}
}
}
 
Share this answer
 
Comments
CHill60 29-May-13 11:30am    
You've posted your code in answer to your own question.
Use the Improve question link if you want to add this to your post.
If you found the correct answer as a result of Orcus Lyigun's comment then it is polite to offer them the chance to post their suggestion as the solution
If you still need an answer to this question you will need to delete this solution

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