GridView
<asp:GridView ID="GridView1" runat="server">
<Columns>
<asp:BoundField HeaderText="年度" DataField="Related_Party_Year" ItemStyle-Width="5%" />
<asp:BoundField HeaderText="次別" DataField="Related_Party_Time" ItemStyle-Width="5%" />
<asp:BoundField HeaderText="ID" DataField="ID1" ItemStyle-Width="10%" />
<asp:BoundField HeaderText="姓名" DataField="Name" ItemStyle-Width="5%" />
</Columns>
</asp:GridView>
HeaderText是表头显示的 ,DataField对应数据库中的栏位
radioButton
GroupName="group" 用来设定一个组单选
CheckBoxList复选框 RepeatDirection排列的方向
<asp:CheckBoxList id="chkList" runat="server" RepeatDirection="Horizontal">
<asp:ListItem >年度</asp:ListItem>
<asp:ListItem >次別</asp:ListItem>
<asp:ListItem >次別</asp:ListItem>
<asp:ListItem >次別</asp:ListItem>
</asp:CheckBoxList>
循环选中的项
foreach (ListItem chk in chkList.Items)
{
if (chk.Selected)
{
}
}
如何通过全选选中其他的复选
protected void chkAll_CheckedChanged(object sender, EventArgs e)
{
if (chkAll.Checked)
{
chkList.Enabled = false;
for (int b = 0; b < chkList.Items.Count; b++)
{
this.chkList.Items[b].Selected = true;
}
}
else
{
chkList.Enabled = true;
chkList.ClearSelection();
}
}
进入页面就绑定全选
chkAll_CheckedChanged(null, null);