如何通过CheckBox在GridView中选择一个项目 [英] How To Select One Item In GridView Via A CheckBox

查看:92
本文介绍了如何通过CheckBox在GridView中选择一个项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

美好的一天所有,

我的Gridview有这个小问题..如果我检查所有项目它将发送消息但是如果我只检查一个项目它将不会发送消息,除非我检查项目No One



查看代码



Good Day All,
I have this little issue with my Gridview.. if i check all the items it will send message but if i check only one item it will not send message unless I check the Item No One

see the code

  foreach (GridViewRow row in GridView1.Rows)
            {
                if (row.RowType == DataControlRowType.DataRow)
                {

                    CheckBox cb = (CheckBox)row.FindControl("Check");
                    if (cb.Checked == true)
                    {
                        if (cb != null && cb.Checked)
                        {
// a simple javascript that says Checked
    MyClass.MyAlert(this, "Checked", "123");
    }
                    }

  else
                    {
                        MyClass.MyAlert(this, "Not Checked", "123");
                        
                        return;
                    }
}
}

/*like i said before it worked perfectly fine if i check all the items, but if i check one items it will not work.... Am I missing something?.. Kindly Assist me

thanks for your valued time...i really do appreciate them
*/

推荐答案

不需要其他部分权利,



当您检查条件时,您将进一步查看已检查的值,然后使用其他部分,



删除其他内容并重试..
Not need of else part right,

As you checking condition, you will go further only for checked values, then what is the use of else part,

Remove else and try again..


这篇关于如何通过CheckBox在GridView中选择一个项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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