Click here to Skip to main content
15,921,548 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I want get my css class fro specific class. But Css Class not found. I tried by below code. But it's not working.



Regards,

Shahana

What I have tried:

protected void gc_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
TextBox txtMinValue = e.Row.Cells[2].FindControl("txtMinValue") as TextBox;
e.Row.Cells[2].CssClass = "txtBox";
TextBox txtMaxValue = e.Row.Cells[3].FindControl("txtMaxValue") as TextBox;
e.Row.Cells[3].CssClass = "txtBox";
CheckBox chkSelect = e.Row.Cells[4].FindControl("chkSelect") as CheckBox;

}
}
Posted
Updated 28-Sep-16 0:35am
Comments
pparya27 28-Sep-16 6:14am    
What is the problem exactly?
ChienVH 28-Sep-16 6:21am    
You need to post the error here.

1 solution

C#
protected void gc_RowDataBound(object sender, GridViewRowEventArgs e)
{
	if (e.Row.RowType == DataControlRowType.DataRow)
	{
		TextBox txtMinValue = e.Row.Cells[2].FindControl("txtMinValue") as TextBox;
		if (e.Row.Cells[2].Text == "abc")
		{
		   e.Row.CssClass = "txtBox"; 
		}		
		TextBox txtMaxValue = e.Row.Cells[3].FindControl("txtMaxValue") as TextBox;		
		if (e.Row.Cells[2].Text == "def")
		{
		   e.Row.CssClass = "txtBox"; 
		}
		CheckBox chkSelect = e.Row.Cells[4].FindControl("chkSelect") as CheckBox;
	}
}
 
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