0

我正在使用gridview,我的问题是如果用户选择第二个复选框,则用户只能在网格中选择一个复选框,我们将取消选中。我尝试使用 javascript,但这对我不起作用,请您帮帮我,我该怎么做。下面是我的网格视图

    <data:EntityGridView ID="gvService" Width="100%"  DataKeyNames="PriceSystemID" runat="server"
                                            OnRowEditing="GridView1_RowEditing" OnRowCommand="gvServices_ItemCommand" AutoGenerateColumns="False"
                                            OnRowDeleting="gvService_RowDeleting" ShowFooter="true" OnRowCancelingEdit="gvService_RowCancelingEdit" 
                                            >
                                            <Columns>
                                                <asp:TemplateField HeaderText="Service">
                                                    <ItemTemplate>
                                                        <data:EntityDropDownList runat="server" ID="dataServiceTypeId1"  DataSourceID="ServiceTypeIdServiceTypesDataSource"
                                                            DataTextField="Description" DataValueField="ServiceTypeId" SelectedValue='<%# Bind("ServiceTypeID") %>' Width="200px"
                                                            AppendNullItem="true" Required="true" NullItemText="< Please Choose ...>" ErrorText="Required" />
                                                        <data:ServiceTypesDataSource ID="ServiceTypeIdServiceTypesDataSource" runat="server"
                                                            SelectMethod="GetAll" />
                                                    </ItemTemplate>
                                                    <EditItemTemplate>
                                                        <data:EntityDropDownList runat="server" ID="dataServiceTypeId2" DataSourceID="ServiceTypeIdServiceTypesDataSource"
                                                             DataTextField="Description" DataValueField="ServiceTypeId" Width="200px" AutoPostBack="true"
                                                            SelectedValue='<%# Bind("ServiceTypeID") %>' AppendNullItem="true" Required="true"
                                                            NullItemText="< Please Choose ...>" ErrorText="Required" />
                                                        <data:ServiceTypesDataSource ID="ServiceTypeIdServiceTypesDataSource" runat="server"
                                                            SelectMethod="GetAll" />
                                                    </EditItemTemplate>
                                                    <FooterTemplate>
                                                      <data:EntityDropDownList runat="server" ID="dataServiceTypeId3" DataSourceID="ServiceTypeIdServiceTypesDataSource"
                                                            AutoPostBack="true" DataTextField="Description" DataValueField="ServiceTypeId" Width="200px"
                                                            SelectedValue='<%# Bind("ServiceTypeID") %>' AppendNullItem="true" Required="true"
                                                            NullItemText="< Please Choose ...>" ErrorText="Required" />
                                                        <data:ServiceTypesDataSource ID="ServiceTypeIdServiceTypesDataSource" runat="server"
                                                            SelectMethod="GetAll" />
                                                    </FooterTemplate>
                                                </asp:TemplateField>
                                                <asp:TemplateField HeaderText="Default">
                                                    <ItemTemplate>
                                                        <asp:CheckBox ID="chkDefault" Checked='<%# Bind("IsDefault") %>'   
                                                            runat="server" />
                                                    </ItemTemplate>
                                                    <EditItemTemplate>
                                                        <asp:CheckBox ID="chkDefault" Checked='<%# Bind("IsDefault") %>' runat="server"   />
                                                    </EditItemTemplate>
                                                    <FooterTemplate>
                                                      <asp:CheckBox ID="chkDefault" Checked='<%# Bind("IsDefault") %>' runat="server"   />

                                                    </FooterTemplate>
                                                </asp:TemplateField>

' CausesValidation="false">

  <EmptyDataTemplate>
 </EmptyDataTemplate>

    </data:EntityGridView>
4

1 回答 1

1

一个基本问题(可能是您的答案):如果用户只能选择一个,为什么要使用复选框。使用带有适当分组的单选按钮,浏览器将处理单选。希望我足够清楚。当用户有多个选项可供选择时,使用复选框,否则,使用单选按钮进行单选。

于 2012-12-17T07:04:41.507 回答