有关将Gridview与复选框一起使用的问题 [英] Question Related to using Gridview with checkbox

查看:59
本文介绍了有关将Gridview与复选框一起使用的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何获取gridview中已标记复选框的Datakeys值?
然后使用这些数据键触发删除命令.

how to get the Datakeys value of marked checkbox in gridview?
and then fire delete command using these datakeys.

推荐答案

//Loop through all the rows in gridview
foreach(GridViewRow gvrow in gvUserDetails.Rows)
{
    //Finiding checkbox control in gridview for particular row
    CheckBox chkdelete = (CheckBox)gvrow.FindControl("chkdelete");
    //Condition to check checkbox selected or not
    if(chkdelete.Checked)
    {
        //Getting UserId of particular row using datakey value
        int usrid = Convert.ToInt32(gvUserDetails.DataKeys[gvrow.RowIndex].Value);
        
        //Delete logic by using above key value.
    }
}


这篇关于有关将Gridview与复选框一起使用的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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