首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

用户控件中取值的有关问题

2011-12-29 
求助用户控件中取值的问题在DataGrid中添加一列为模板列,模板列中放置一个CheckBox.然后将该DataGrid保存

求助用户控件中取值的问题
在DataGrid中添加一列为模板列,模板列中放置一个CheckBox.
然后将该DataGrid保存为一用户控件.
在一个ASP.NET页中使用上述控件,问题是如何取出该控制中选中的项呢?

[解决办法]
做成公用属性或方法如:public string GetSelectedId(){ ///}
[解决办法]
CheckBox tb=(CheckBox)e.Item.FindControl(string id);
[解决办法]
在用户控件里设一个属性,取得checkbox的值
[解决办法]
public string str
{
get
{ return str;}
set
{
foreach(DataGridItem dl in this.DataGrid1.Items)
{
CheckBox chk=(CheckBox)dl.FindControl( "chk ");
if(chk.Checked)
{
str=....;
}

}
}

热点排行