Link to home
Start Free TrialLog in
Avatar of doramail05
doramail05Flag for Malaysia

asked on

check only one checkbox in gridview

i have list of items which have checkboxes in front,
so i try to only allow only one checkbox can be checked in the gridview.
<asp:GridView ID="gvLS" runat="server" 
        AutoGenerateColumns="False" AllowPaging="True" CssClass="datatable"
                    CellPadding="5" BorderWidth="1px" BorderColor="#6E6E6E" 
                 Font-Names="Arial" Font-Size="Small" 
                PageSize="5" GridLines="None" AlternatingRowStyle-BackColor="#efefef" 
            Width="300px" 
                 HeaderStyle-HorizontalAlign="Left" 
            AllowSorting="True"   >
                    <HeaderStyle BackColor="#BDBDBD" />
                    <Columns>
                    <asp:TemplateField>
                        <ItemTemplate>
                            <asp:CheckBox id="cbCheckLevel" runat="server" />
                            <asp:Label ID="lblIDField" Visible="false" Text='<%# Eval("id") %>' runat="server" />
                    
                         </ItemTemplate>
                    </asp:TemplateField>

                    <asp:BoundField HeaderText="Level Code" DataField="code" 
                            SortExpression="code" HeaderStyle-ForeColor="Black"
                            HeaderStyle-CssClass="first" ItemStyle-CssClass="first" ReadOnly="True"  
                            HeaderStyle-HorizontalAlign="Left"  ItemStyle-HorizontalAlign="Left">
<HeaderStyle CssClass="first" ForeColor="Black"></HeaderStyle>

<ItemStyle CssClass="first"></ItemStyle>
                        </asp:BoundField>
                        
                            <asp:BoundField HeaderText="Level Name" DataField="name" 
                            SortExpression="name" HeaderStyle-ForeColor="Black"
                            HeaderStyle-CssClass="first" ItemStyle-CssClass="first" ReadOnly="True"  
                            HeaderStyle-HorizontalAlign="Left"  ItemStyle-HorizontalAlign="Left">
<HeaderStyle CssClass="first" ForeColor="Black"></HeaderStyle>

<ItemStyle CssClass="first"></ItemStyle>
                        </asp:BoundField>
                       
                     
                    </Columns>
        
                         </asp:GridView>

Open in new window

Avatar of Sarika30
Sarika30
Flag of India image

try using radio buttons in the same group.
ASKER CERTIFIED SOLUTION
Avatar of doramail05
doramail05
Flag of Malaysia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
It is using radio buttons only...thts what i suggested :)