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

关于datagrid 中 checkbox有关问题

2012-02-02 
关于datagrid 中 checkbox问题我在datagrid中有一列是采用checkbox的,在datagrid外有一个按钮现在我要的作

关于datagrid 中 checkbox问题
我在datagrid   中有一列是采用checkbox的,在datagrid外有一个按钮
现在我要的作用是:点击按钮,会对datagrid   中   checkbox   选为true   做出
提示nihao   :
for   (int   i   =   0;   i   <   dg.Items.Count;   i++)
                {
                        Boolean   cked   =   ((CheckBox)dg.Items[i].FindControl( "ckb ")).Checked;
                        if   (cked)
                        {
                                Response.Write( "nihao ");  
                        }
                }
为什么上面的代码   当我选择其中的几个checkbox   控件,点击按钮后一点反映也没有啊
谢谢了,急用啊,急急!

[解决办法]
现在只用05的GridView, 从你代码来看似乎没有什么问题,试下下面代码:

foreach(DataGridItem Row in dg.Items)
{
Boolean cked = ((CheckBox)Row.FindControl( "ckb ")).Checked;
if (cked)
{
Response.Write( "nihao ");
}
}

你最好加个断点跟踪一下。

热点排行