Click here to Skip to main content
15,911,786 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hope u r doing well.

I have a listview with two sqldatasource outside. Inside the listview there is a label and a checkboxlist. The label is to display the category titles. I wanna databind the each checkboxlist to its coressponding data. I don't know how to do. Please explain me with abit of code as i am a beginner developer. Thanks so much for your help. I googled alot and found people with same problems and others solutions to their problems. But i don't know how to re-use those solution in my program. :(

That's the code i have. I don't have anything in codebehind. With this code, it shows the data with different categories but all the checkboxlists show same thing, which is right for the first checkboxlist. Thanks so much again.

VB
<asp:ListView ID="ListView1" runat="server" DataSourceID="ListViewSqlDataSource" >
       <ItemTemplate>
           <asp:Label ID="CategoryNameLabel" runat="server"><%# Eval("CategoryName") %></asp:Label>
           <asp:CheckBoxList ID="CheckBoxList1" runat="server" DataSourceID="SqlDataSource1" DataValueField="SortOrder" DataTextField="DocumentName">
           </asp:CheckBoxList>
       </ItemTemplate>
   </asp:ListView>

   <asp:SqlDataSource ID="ListViewSqlDataSource" runat="server" ConnectionString="<%$ xxx:xxx %>"
       SelectCommand="EXEC [Docs].[CategoryList] @UserName = 8882074, @Service = 9">
       <SelectParameters>
           <asp:Parameter DefaultValue="8882074" Name="UserName" />
           <asp:Parameter DefaultValue="9" Name="Service" />
       </SelectParameters>
   </asp:SqlDataSource>

     <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ xxx:xxx;"

       SelectCommand="EXEC Docs.[DocumentList] @UserName = 8882074, @Service = 9,  @YearGroup = NULL, @Category = 1">
       <SelectParameters>
           <asp:Parameter DefaultValue="8882074" Name="UserName" />
           <asp:Parameter DefaultValue="9" Name="Service" />
           <asp:Parameter DefaultValue="1" Name="YearGroup" />
           <asp:Parameter DefaultValue="1" Name="Category" />
       </SelectParameters>

   </asp:SqlDataSource>
Posted
Updated 18-Jan-12 1:21am
v2
Comments
Jephunneh Malazarte 19-Jan-12 1:39am    
see answer to your post in asp.net forum.

http://forums.asp.net/t/1760253.aspx/1?How+to+databind+checkboxlist+inside+ListView+with+SqlDataSource+vb+net+

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