checkbox没有value属性
如果实现像asp中<input type="checkbox" value="<%=rs("id")%>">
类似获得数据库中表的id?

解决方案 »

  1.   

    但是checkboxlist如何嵌入datagrid内呢?
      

  2.   

    http://community.csdn.net/Expert/TopicView.asp?id=3392367http://community.csdn.net/Expert/TopicView.asp?id=3348089http://community.csdn.net/Expert/TopicView.asp?id=3313145
      

  3.   

    <templatecolumn><checkboxlist/><templatecolumn>
      

  4.   

    <asp:DataGrid id="MyDataGrid" runat="server">         <Columns>            
                <asp:TemplateColumn>              <ItemTemplate>
                      <asp:CheckBoxList runat="server"/>
                   </ItemTemplate>              
                </asp:TemplateColumn>
                        </Columns>      </asp:DataGrid>
      

  5.   

    如果改成checkboxlist 那么checkboxlist是在datagrid摸板列内的,如何给checkboxlist绑定数据呢?
      

  6.   

    <asp:TemplateColumn>
                  <ItemTemplate>
                      <asp:CheckBoxList runat="server" DataSource=<%#DataBinder.Eval(...)%> .....一样得绑定方式,改怎么写就怎么写/>
                   </ItemTemplate>              
                </asp:TemplateColumn>
      

  7.   

    CheckBoxList也不是太灵活,
    你可以另加一个隐藏列,
    当check被选中是,取隐藏列得值
      

  8.   

    有没有实例,包含后台代码给CheckBoxList赋值的例。
      

  9.   

    最好是在绑定DataGrid后在绑定CheckBoxList,写在ItemBound事件里面
      

  10.   

    用模板列将checkedbox加到模板列中,然后对模板列进行编辑绑定都可以:
    用FindControl(“checkedid”)找到该控件!然后编辑就可以了!
      

  11.   

    http://blog.csdn.net/lihonggen0/archive/2004/08/13/74202.aspx
      

  12.   

    for(int i=0; i<DataGrid.Items.Count; i++)
    {
    CheckBox check=(CheckBox)item.FindControl("check");
    .....
    }
      

  13.   

    foreach(DataGridItem oItem in myDG2.Items)
    {
    myCL=(CheckBoxList)oItem.FindControl("CheckBoxList1");
    int qxstr=0;
    foreach(ListItem ThisOne in myCL.Items)
    {
    if(ThisOne.Selected)
    {
    ....
    }
    else
    {
    ...... }
    }
      

  14.   

    使用模板列,在模板列中加入html的checkbox,但是声明成runat=server,如:
    <ItemTemplate>
    <input type="checkbox" runat="server" id="contract" NAME="contract" />
    </ItemTemplate>
    然后在.cs类文件中这样取值:
    foreach(DataGridItem di in this.DataGrid1.Items)
    {
    HtmlInputCheckBox cb = (HtmlInputCheckBox)di.FindControl("contract") ;
    if(cb !=null && cb.Checked)
    {
    //添加处理代码
    }
    }
      

  15.   

    用html控件实现了。没有用runat=server
    结帖了。