1
如果我有一個網格視圖包含checkbox
chk_short_day爲模板字段:如何只允許gridview中的一個複選框?
<asp:GridView ID="grv_week_day" runat="server" AutoGenerateColumns="False"
CssClass="datatable" OnRowDataBound="grv_week_day_RowDataBound" >
<Columns>
<asp:TemplateField HeaderStyle-Height="40px" HeaderStyle-Width="200px">
<HeaderTemplate>
<h2>week days
</h2>
</HeaderTemplate>
<ItemTemplate>
<asp:Label ID="lbl_weekday" runat="server" CssClass="title" Text='<%# Bind("WeekDay") %>'></asp:Label>
</ItemTemplate>
<HeaderStyle Height="40px" Width="100px"></HeaderStyle>
</asp:TemplateField>
<asp:TemplateField HeaderStyle-Height="40px">
<HeaderTemplate>
<h2>Attendance Type</h2>
</HeaderTemplate>
<ItemTemplate>
<asp:DropDownList ID="drp_att" runat="server" AutoPostBack="True" Width="200px" Enabled="false"
CausesValidation="false" OnSelectedIndexChanged="OnSelectedIndexChanged_drp">
</asp:DropDownList>
</ItemTemplate>
<HeaderStyle Height="40px"></HeaderStyle>
</asp:TemplateField>
<asp:TemplateField HeaderStyle-Height="40px">
<HeaderTemplate>
<h2>From
</h2>
</HeaderTemplate>
<ItemTemplate>
<asp:Label ID="lbl_From" runat="server"></asp:Label>
</ItemTemplate>
<HeaderStyle Height="40px"></HeaderStyle>
</asp:TemplateField>
<asp:TemplateField HeaderStyle-Height="40px">
<HeaderTemplate>
<h2>To
</h2>
</HeaderTemplate>
<ItemTemplate>
<asp:Label ID="lbl_To" runat="server"></asp:Label>
</ItemTemplate>
<HeaderStyle Height="40px"></HeaderStyle>
</asp:TemplateField>
<asp:TemplateField HeaderText="Short Day">
<ItemTemplate>
<asp:CheckBox ID="chk_short_day" runat="server" AutoPostBack ="true" OnCheckedChanged="chk_short_day_CheckedChanged" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
如何只允許一個GridView中的檢查,如果用戶檢查的一個複選框,我想自動取消其餘部分。?
應用的JavaScript – mshsayem
http://www.c-sharpcorner.com/UploadFile/4d9083/how-to-allow-user-to-check-only-one-row-at-a-time-in -grid-vi/ –
@mshsayem問題沒有用JS標記,大概不是一個選項,因爲最終用戶可以簡單地禁用JS。 – sab669