473,473 Members | 1,817 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Repeater Difficulties

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.D ataItem,"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!
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #1
1 1132
Well if you want an idea, I don't belive you can use that
<%#DataBinder.Eval(Container.DataItem,"sectionTitl e")%> stuff in the
HeaderTemplate, because there is no data there to be looked at yet. What I
believe you can do is pop an asp control in there and set that value from
code.

<HeaderTemplate>
<tr><td
colspan="2"><asp:label id="mySectionLabel" runat="server" /></td>
</tr>
</HeaderTemplate>

then somewhere down in your code

SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(ds,"links");
mySectionLabel.text = ds.myDataTableName(0).sectionTitle 'Typed Dataset
mySectionLabel.text = ds.tables("myDataTableName").rows(0)("sectionTitle ")
'unTyped Dataset (I think that syntax is correct..I took one look at that
and learned how to use typed Datasets :) )
rptLinks.DataSource = ds;
rptLinks.DataBind();


"Philip Townsend" <pt*******@v1tech.com> wrote in message
news:Oj**************@TK2MSFTNGP11.phx.gbl...
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.D ataItem,"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!
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Ed Allan | last post by:
http://ejaconsulting.com/nestedrepeater/NestedRepeater.txt >-----Original Message----- >Doh! The HTML has all been rendered . . . > >Right click on this link and select 'Save target as ..' >to...
8
by: Invalidlastname | last post by:
Hi, We are developing an asp.net application, and we dynamically created certain literal controls to represent some read-only text for certain editable controls. However, recently we found an issue...
0
by: Amir | last post by:
Hi every one This is the problem: I have a UserControl that contains a Repeater and a few LinkButton. The Repeater generate some linkButton. I use this control for implementing paging solution...
3
by: sorCrer | last post by:
Hi All, Posted after extensive searching! I have a nested repeater control as follows: (Simplified ;-)) <table> <asp:repeater id=parent onItemDataBound=createChild> <tr><td>Level...
8
by: I am Sam | last post by:
Hi everyone, This problem is making me old. I don't want to get any older. I have a multi-nested repeater control as follows: <asp:Repeater ID="clubRep1" Runat="server">...
1
by: olduncleamos | last post by:
Hello all, I am experimenting with the repeater control and ran into something that I wasn't expecting. I would appreciate if the experts can confirm or correct my understanding. Here is a...
2
by: GD | last post by:
I'd like to use a Repeater to display data coming back from a cross-tab report. Because it's a cross-tab, I generally don't know how many columns are coming back. They do follow a certain format: ...
8
by: fernandezr | last post by:
I would like to use a user control as a template inside a repeater. Some of the fields in the control should be hidden depending on whether or not there is data. I'm still a ASP .Net newbie so the...
0
by: uncensored | last post by:
Hello everyone, I'm fairly new at .Net and I have a repeater inside a repeater problem. I will attach my code to this message but basically what I am able to tell when I run my page it tells me...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.