lundi 30 novembre 2020

Listview with checkboxes Asp.net

I have a Listview with labels and checkboxes inside.How to restrict the selection mode of the checkbox to single.I want to select only one checkbox at a time.

Here is my code .aspx page


   <asp:ListView runat="server" ID="ListviewCategories">
                                        <LayoutTemplate>
                                            <table runat="server" id="table1">
                                                <tr runat="server" id="itemPlaceholder">
                                                </tr>
                                            </table>
                                        </LayoutTemplate>
                                        <ItemTemplate>
                                            <tr id="Tr1" runat="server">
                                                <td id="Td2" runat="server">
                                                    <asp:Label runat="server" ID="lblCategoryId" Text='<%#Eval("CategoryId") %>' Visible="false"></asp:Label>
                                                    <asp:Label ID="CategoryName" runat="server" Text='<%#Eval("CategoryName") %>' />
                                                </td>
                                                <td id="Td3" runat="server">
                                                    <asp:CheckBox ID="ChkCategory" runat="server" OnCheckedChanged="ChkCategory_CheckedChanged" AutoPostBack="true" />
                                                </td>
                                            </tr>
                                        </ItemTemplate>
                                    </asp:ListView>





Aucun commentaire:

Enregistrer un commentaire