Username: Password:

在DataGrid中用CheckBox控制-.NET教程,数据库应用
来源:作者: 发布时间:2007-12-26 02:04:54


将模板列的checkbox的autopostback属性配置为true,因为在模板列中的控件没有事件,故在aspx页面写事件程式,同时将checkbox的oncheckedchanged事件配置为所需要的事件程式。示例如下:





void check_change(object sender, eventargs e)

{

textbox txtdescription;

foreach(datagriditem item in itemsgrid.items)

{

selection = (checkbox)item.findcontrol("chkenabled");

txtdescription = (textbox)item.findcontrol("txtdescription");

if (selection.checked) { txtdescription.enabled=false; }

else { txtdescription.enabled=true;}

}

}

这样,当选中checkbox时,textbox中的内容将不可编辑,这个例子的缺陷在于没有使用就javascript灵活,因为每次都要和服务器通信。



喜欢本文,那就收藏到:

    Del.icio.us Google书签 Digg Live Bookmark Technorati Furl Yahoo书签 Facebook 百度搜藏 新浪ViVi 365Key网摘 天极网摘 和讯网摘 博拉网 POCO网摘 添加到饭否 QQ书签 Digbuzz我挖网
相关评论  我也要评论
还没有关于此文章的相关评论!
  • 昵称: (为空则显示guest)
  • 评论分数: ★ ★ ★★★ ★★★★ ★★★★★
  • 评论内容:(不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规。
  • 导航
    赞助商
    文章类别
    订阅