获取复选框的值放在gridview内作为模板字段。 [英] Getting the value of checkbox placed inside gridview as a templatefield.

查看:65
本文介绍了获取复选框的值放在gridview内作为模板字段。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我有一个页面显示gridview,其中包含在页面加载时计算的数据,其中有两列,一列带复选框,另一列带有radiobutton。我把这两个字段作为模板字段。我想得到所有行的按钮按钮和复选框的值按钮按钮。如何得到这个值

解决方案

有(INT I = 0; I< GrivdView.Rows.Count;我++)?
{
复选框CBOX =(复选框)grdUsers.Rows [I] .Cells [1] .FindControl( 复选框); //写ID的你的FindControl复选框这里和写入正确的小区索引到细胞[1]
如果(CBOX!= NULL)
{
//现在你可以使用复选框
播放}
单选按钮rButton =(单选)grdUsers.Rows [I] .Cells [2] .FindControl( ); //写ID的你的FindControl RADIOBUTTON这里和写入正确的小区索引进入细胞的[1]
如果(rButton!= NULL)
{
//现在你可以玩单选按钮
}
}


Hello everyone,

I have one page which displays gridview with data calculated on page load which have two columns one with checkbox and other with radiobutton. I have taken this two fields as a templatefield. I want to get the values of radiobutton and checkbox for all the rows ON BUTTON CLICK. How to get this values?

解决方案

for (int i = 0; i < GrivdView.Rows.Count; i++)
            {
                CheckBox cBox = (CheckBox)grdUsers.Rows[i].Cells[1].FindControl("checkbox");//Write the ID of you CheckBox here in FindControl and write the correct cell index into Cells[1]
                if (cBox != null)
                {
                    //now you can play with check box
                }
                RadioButton rButton = (RadioButton)grdUsers.Rows[i].Cells[2].FindControl("");//Write the ID of you RadioButton here in FindControl and write the correct cell index into Cells[1]
                if (rButton != null)
                {
                    //now you can play with Radio Button
                }
            }


这篇关于获取复选框的值放在gridview内作为模板字段。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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