在DataGrid中前面一列加了一个CheckBox,现在想选中CheckBox控件时,就将信息传递到后台,然后实现该行数据的更新,请问该怎么做呢??

解决方案 »

  1.   

    make sure you set CheckBox's AutoPostBack=true and hook up its CheckedChanged event with some handlervoid YourCheckBoxHandler(object sender, EventArgs e)
    {
      CheckBox cb = (CheckBox)sender;
      DataGridItem dgi = (DataGridItem)cb.Parent.Parent;
      //...
    }http://www.codeproject.com/aspnet/datagridcheckbox.asphttp://www.codeproject.com/aspnet/dgcheckboxcolumn.asp
      

  2.   

    http://singlepine.cnblogs.com/articles/266538.html
      

  3.   

    Private Function SeletedID() As String '获得被选择到的项的ID
            Dim oDataGridItem As DataGridItem
            Dim chkExport As CheckBox
            '循环取的DataGrid控件中选定项的值
            Dim StrSql As String        For Each oDataGridItem In ArticleMe.Items
                chkExport = oDataGridItem.FindControl("chkExport")
                If chkExport.Checked = True Then
                    CheckmimOne = True
                    StrSql += "'" + oDataGridItem.Cells(1).Text.Trim + "',"
                End If
            Next
            '显示选中项的值
            StrSql = StrSql.Substring(0, StrSql.LastIndexOf(","))
            SeletedID = StrSql
        End Function使用MyclassDA.ForArticleDelete(SeletedID, 0)---SeletedID是上面的函数
    这个函数可能返回的值是“1”或者“'1','2','3'”
    看你选择了多少个了这个是我批量删除文章的功能的代码,希望对你有用。
      

  4.   

    http://singlepine.cnblogs.com/articles/266538.html 小山的能高定
      

  5.   

    http://community.csdn.net/Expert/topic/4476/4476626.xml?temp=.0194208
    欢迎楼主来顶我的贴子。注册一个小魔法师
      

  6.   

    首先你的checkbox要设置为autopostback = true,其他的你综合上面很容易就能得到啊 
    http://support.microsoft.com/?scid=kb;zh-cn;306227,看下这个