I need help with the following:
The code below (and code-behind) creates a nested Repeater control, that looks like this:
Desserts
[ ] Cakes
[ ] Cookies
[ ] Ice Cream
[ ] Mousse
[ ] Pastries
[ ] Pies
Dining
[ ] African
[ ] Chinese
[ ] Contemporary
[ ] French
Instead of using a repeater inside, would it be better to use a DataGrid control?
Also, I want to be able to select all items in a given category (adding a checkbox beside the category), and entering into the db. (later, I'll want to read the saved values and populate the checkboxes accoringly).
For the checkbox ID (for sub-categories - the only ones I'm interested in collecting) I tried id="chkbox_<%# DataBinder.Eval(Container.DataItem, "[\"iscID\"]")%>" which returns the error, "Parser Error Message: The server tag is not well formed."
The Code-Behind:
The code below (and code-behind) creates a nested Repeater control, that looks like this:
Desserts
[ ] Cakes
[ ] Cookies
[ ] Ice Cream
[ ] Mousse
[ ] Pastries
[ ] Pies
Dining
[ ] African
[ ] Chinese
[ ] Contemporary
[ ] French
Instead of using a repeater inside, would it be better to use a DataGrid control?
Also, I want to be able to select all items in a given category (adding a checkbox beside the category), and entering into the db. (later, I'll want to read the saved values and populate the checkboxes accoringly).
For the checkbox ID (for sub-categories - the only ones I'm interested in collecting) I tried id="chkbox_<%# DataBinder.Eval(Container.DataItem, "[\"iscID\"]")%>" which returns the error, "Parser Error Message: The server tag is not well formed."
Code:
<asp:repeater id="parentRepeater" runat="server">
<itemtemplate>
<span class="contentHeader1">
<%# DataBinder.Eval(Container.DataItem, "icDescription") %>
</span><br>
<table>
<!-- start child repeater -->
<asp:repeater id="childRepeater" datasource='<%# ((DataRowView)Container.DataItem).Row.GetChildRows("myrelation") %>' runat="server">
<itemtemplate>
<tr>
<td width="10px"> </td>
<td>
<input type="checkbox" id="checkbox_ID" runat="server">
</td>
<td><%# DataBinder.Eval(Container.DataItem, "[\"iscDescription\"]")%> </td>
</tr>
</itemtemplate>
</asp:repeater>
<!-- end child repeater -->
</table>
<br>
</itemtemplate>
</asp:repeater>
The Code-Behind:
Code:
public void BindData()
{
// using nested repeater
SqlConnection objConn = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
SqlDataAdapter cmd1 = new SqlDataAdapter("SELECT * " +
"FROM InterestCategory " +
"ORDER BY icDescription ASC", objConn);
DataSet ds = new DataSet();
cmd1.Fill(ds, "InterestCategory");
//Create a second DataAdapter for the Titles table.
SqlDataAdapter cmd2 = new SqlDataAdapter("SELECT * " +
"FROM InterestSubCategory " +
"ORDER BY iscDescription ASC", objConn);
cmd2.Fill(ds,"InterestSubCategory");
//Create the relation bewtween the Authors and Titles tables.
ds.Relations.Add("myrelation",
ds.Tables["InterestCategory"].Columns["icID"],
ds.Tables["InterestSubCategory"].Columns["icID"]);
parentRepeater.DataSource = ds.Tables["InterestCategory"];
Page.DataBind();
//myRepeater.DataSource = ds;
//myRepeater.DataBind();
objConn.Close();
}