Click here to Skip to main content
15,890,845 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to bring a checkboxlist in the columns collections of the gridview. How to add values to it..I tried it the following way but wasnt a success. Please help.
XML
<asp:GridView ID="GridView1" runat="server">
        <Columns>
        <asp:TemplateField>
        <ItemTemplate>
        <asp:CheckBoxList runat="server" ID="mycheckboxlst" DataValueField="city"></asp:CheckBoxList>
        </ItemTemplate>
        </asp:TemplateField>
        </Columns>
        </asp:GridView>
Posted
Updated 6-Jan-11 1:26am
v3

see THIS[^] neat article will help you towards.

Thanks
 
Share this answer
 
Comments
Sandesh M Patil 6-Jan-11 7:30am    
good answer
Hiren solanki 6-Jan-11 7:33am    
Thanks SMP.
You can add a SqlDataSource. Configure it so that it fetches your desired list from DB. Then attach it to the CheckBoxList as shown below.
XML
<asp:CheckBoxList runat="server" ID="mycheckboxlst" DataValueField="City"
        DataSourceID="SqlDataSource1" DataTextField="FirstName"></asp:CheckBoxList>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server"
        ConnectionString="<%$ ConnectionStrings:SampleDatabaseConnectionString %>"
        SelectCommand="SELECT * FROM [CustomerInfo]"></asp:SqlDataSource>


Note that you need to set DataValueField and DataTextField properties to bind the text and value for each check box.
 
Share this answer
 
Use the DataTextField and DataValueField also use..
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900