在rowdatabound中找不到Cssclass [英] Cssclass not found in rowdatabound

查看:68
本文介绍了在rowdatabound中找不到Cssclass的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我想从特定课程中获取我的css课程。但没有找到Css类。我试过下面的代码。但它没有用。







问候,



Shahana



我尝试过:



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)作为CheckBox;



}

}

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;

}
}

推荐答案

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;
	}
}


这篇关于在rowdatabound中找不到Cssclass的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆