gridview复选框读取调用功能 [英] gridview checkbox read call function

查看:51
本文介绍了gridview复选框读取调用功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将myCommand设置为新的SqlCommand(sqlselect,myConnection)
将MyReader昏暗为SqlDataReader
myConnection.Open()
myReader = myCommand.ExecuteReader()
如果是myReader.HasRows然后
而myReader.Read()
将Dim作为Boolean = DirectCast(FindControl("chkSelect"),CheckBox)进行检查.
如果被选中则
empmail = myReader(column)
fn_AttachGrid(empmail)
其他
如果结束
结束时
myReader.Close()
myConnection.Close()
其他
如果结束


我在gridview中有一个gridview和一个复选框项
当按下按钮时,它应该遍历所有选中复选框的项目.不确定是否是您的要求.

 受保护的 无效 Button1_Click(对象发​​件人,EventArgs e)
{
 // 遍历GridView中的所有行
  foreach (GridViewRow di  in  GridView1.Rows中)
 {
   CheckBox chkBx =(CheckBox)di.FindControl(" );
   如果(chkBx!= && chkBx.已检查)
   {
      /// 将您的代码放在此处
}
 }
} 


Dim myCommand As New SqlCommand(sqlselect, myConnection)
Dim myReader As SqlDataReader
myConnection.Open()
myReader = myCommand.ExecuteReader()
If myReader.HasRows Then
While myReader.Read()
Dim isChecked As Boolean = DirectCast(FindControl("chkSelect"), CheckBox).Checked

If isChecked Then
empmail = myReader(column)
fn_AttachGrid(empmail)
Else
End If
End While
myReader.Close()
myConnection.Close()
Else
End If


i have a gridview and a checkbox item in gridview
when button is pressed it should iterate through all the items where check box is checked

解决方案

Please go through below code, see if it helps. Not sure though if it is your requirement.

protected void Button1_Click(object sender, EventArgs e)     
{
 // Looping through all the rows in the GridView          
 foreach (GridViewRow di in GridView1.Rows)         
 {          
   CheckBox chkBx = (CheckBox)di.FindControl("chkSelect");              
   if (chkBx != null && chkBx.Checked)            
   {
      /// put your code here             
   }         
 } 
} 


这篇关于gridview复选框读取调用功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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