foreach( ListItem cb in CheckBoxList1.Items)
{
cb.Selected = true;
}

解决方案 »

  1.   

    ListItem ?属于哪个命名空间的?我怎么找不到?
      

  2.   

    for(int i=0;i<CheckBoxList1.Items.Count;i++)
    {
    CheckBoxList1.Items[i].Selected=true;
    }
      

  3.   

    前台用datagrid的摸板列<asp:datagrid id="mydatagrid" Runat="server" Width="775px" AlternatingItemStyle-VerticalAlign="Middle"
    DataKeyField="lend_id" AutoGenerateColumns="False" CellPadding="3" BackColor="White" BorderWidth="2px"
    GridLines="None" CellSpacing="1" BorderStyle="Ridge" BorderColor="White" AllowSorting="True">
    <asp:TemplateColumn HeaderText="是否提交">
    <columns> <ItemStyle HorizontalAlign="Center"></ItemStyle>
    <ItemTemplate>
    <asp:CheckBox id="Chx" Runat="server"></asp:CheckBox>
    </ItemTemplate>
    <FooterStyle HorizontalAlign="Center"></FooterStyle>
    <EditItemTemplate>
    <asp:CheckBox id="chx" Runat="server"></asp:CheckBox>
    </EditItemTemplate>
    </asp:TemplateColumn>
    然后加一个按钮,作用当点击后,全部选种
    在.vb或.cs文件中,在这个按钮的点击时间中
    将摸半列中的check全部选种
      

  4.   

    “ListItem ?属于哪个命名空间的?我怎么找不到?”
    你要查帮助呀。
    是System.Web.UI.WebControls 命名空间的。
      

  5.   

    朋友,别听楼上的那些哥们的,他们都在逗你玩。
    只要这样就可以:for(int i=0;i<CheckBoxList1.Items.Count;i++)
    {
          CheckBoxList1.Items[i].Selected;
    }在数据加载到 CheckBoxList1 以后使用。
      

  6.   

    谢谢大家了!
    我用的是window控件C#,
    Items[i].Selected;也是不行的。
    我用下面这个了,可以。
    CheckBoxList1.SetItemChecked(i,true)
      

  7.   

    根本就没有这个属性
    CheckBoxList1.Items[i].Selected;
      

  8.   

    应该这样winform
    for(int i=0;i<checkedListBox1.Items.Count;i++)
    {  
    checkedListBox1.SetItemChecked (i,true);
    }
      

  9.   

    CheckBoxList1.Items[i].Selected;这是那个猪在蒙人