P
Philip Townsend
I have a repeater control that writes an HTML table. Itv needs to
display a header in the first row, then a list of records produced from
a SQL table. The header text is also produced from the SQL query. The
items within the <ItemTemplate> section appear as needed, however, the
header text (which is contained in the <HeaderTemplate> section) does
not. Here is the code sample:
<asp:Repeater ID="rptLinks" Runat="server">
<HeaderTemplate>
<tr><td
colspan="2"><%#DataBinder.Eval(Container.DataItem,"sectionTitle")%></td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr style="font-size:8pt">
<td width="10"><img src="images/bullet.gif" vspace="1"
hspace="1"></td>
<td width="140"><a
href="abs.aspx?pgID=<%#DataBinder.Eval(Container.DataItem,"pageID")%>"><
%#DataBinder.Eval(Container.DataItem,"pageTitle")%></a></td>
</tr>
</ItemTemplate>
</asp:Repeater>
The repeater object is bound to a Dataset in the following:
String PType = Request.QueryString["pgID"].ToString();
DataSet ds = new DataSet();
SqlConnection cnx = new
SqlConnection(ConfigurationSettings.AppSettings["mainconn"].ToString());
SqlCommand cmd = cnx.CreateCommand();
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "prLeftNavLinks";
cmd.Parameters.Add("@pageID",SqlDbType.Int);
cmd.Parameters["@pageID"].Value = Int32.Parse(PType);
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(ds,"links");
rptLinks.DataSource = ds;
rptLinks.DataBind();
da.Dispose();
cmd.Dispose();
cnx.Dispose();
Any ideas as to why the headertext does not render in the repeater
control? Thanks!
display a header in the first row, then a list of records produced from
a SQL table. The header text is also produced from the SQL query. The
items within the <ItemTemplate> section appear as needed, however, the
header text (which is contained in the <HeaderTemplate> section) does
not. Here is the code sample:
<asp:Repeater ID="rptLinks" Runat="server">
<HeaderTemplate>
<tr><td
colspan="2"><%#DataBinder.Eval(Container.DataItem,"sectionTitle")%></td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr style="font-size:8pt">
<td width="10"><img src="images/bullet.gif" vspace="1"
hspace="1"></td>
<td width="140"><a
href="abs.aspx?pgID=<%#DataBinder.Eval(Container.DataItem,"pageID")%>"><
%#DataBinder.Eval(Container.DataItem,"pageTitle")%></a></td>
</tr>
</ItemTemplate>
</asp:Repeater>
The repeater object is bound to a Dataset in the following:
String PType = Request.QueryString["pgID"].ToString();
DataSet ds = new DataSet();
SqlConnection cnx = new
SqlConnection(ConfigurationSettings.AppSettings["mainconn"].ToString());
SqlCommand cmd = cnx.CreateCommand();
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "prLeftNavLinks";
cmd.Parameters.Add("@pageID",SqlDbType.Int);
cmd.Parameters["@pageID"].Value = Int32.Parse(PType);
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(ds,"links");
rptLinks.DataSource = ds;
rptLinks.DataBind();
da.Dispose();
cmd.Dispose();
cnx.Dispose();
Any ideas as to why the headertext does not render in the repeater
control? Thanks!