foreach(GridViewRow gr in GridView1.Rows)
{
CheckBox chb = (CheckBox)gr.FindControl("chb_check");
if (chb.Checked)
{
string stuID = gr.Cells[2].Text.ToString();
string stuName = gr.Cells[3].Text.ToString();
}
}
我调试的时候stuID,stuName都为空,请问cells[n].Text取的是项中那个数据呢,ItemTemplate,EditItemTemplate??我已经把该列转为模板列了.ItemTemplate,EditItemTemplate里都有控件?我就是想取控件中的值,不想再用findcontrol这个方法
{
CheckBox chb = (CheckBox)gr.FindControl("chb_check");
if (chb.Checked)
{
string stuID = gr.Cells[2].Text.ToString();
string stuName = gr.Cells[3].Text.ToString();
}
}
我调试的时候stuID,stuName都为空,请问cells[n].Text取的是项中那个数据呢,ItemTemplate,EditItemTemplate??我已经把该列转为模板列了.ItemTemplate,EditItemTemplate里都有控件?我就是想取控件中的值,不想再用findcontrol这个方法
解决方案 »
- 插入数据库一条记录后得到id号码
- 问个链表的顺序插入算法
- 命名空间是什么意思?
- c#问题?
- 如果驗證textbox中輸入是字符是否是 正整數?
- 如何在子线程中获取控件的text值
- 程序报错,大家帮忙看看是什么问题!
- 各位大哥!为何不能使用System.Management命名空间?
- 哪有免费发短信的软件下载?至少有三个月时间是免费的哦
- DataSet 数据导出到dbf文件,而且dbf文件要动态生成
- hashtable的一个值如何使用带参的ToString()
- 请教个问题,datatable.clone(),datatable.copy(),datatable.merge()有啥区别???请高手指教??
string stuID = string.Empty;
string stuName = string.Empty;
foreach (GridViewRow gr in GridView1.Rows)
{
chb = gr.FindControl("chb_check") as CheckBox;
if (chb != null && chb.Checked)
{
stuID = (gr.FindControl("id文本框的id") as TextBox).Text;
stuName = (gr.FindControl("name文本框的id") as TextBox).Text;
}
}
同意3楼,微软搞FindControl就是做这个用的!!