J
John
Hi all,
I have a Repeater problem where the code within the <ItemTemplate> and
<AlternatingItemTemplate> tags are not being executed.
<asp:Repeater ID="myRepeater" Runat="server">
<HeaderTemplate>
<table cellspacing="0" cellpadding="0" border="0">
<tr>
<td ID="tdMyHeader" Runat="server">
...
</td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
...
<td><%# DataBinder.Eval(Container.DataItem,
"MyDateTime", "{0:h:mmtt}") %></td>
...
</tr>
</ItemTemplate>
<AlternatingItemTemplate>
<tr>
...
<td><%# DataBinder.Eval(Container.DataItem,
"MyDateTime", "{0:h:mmtt}") %></td>
...
</tr>
</AlternatingItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
The DataSource property on the Repeater is populated with a DataView
containing two records.
....
using (DataView dv = MyDataView())
{
if (dv != null && dv.Count > 0)
{
myRepeater.DataSource = dv;
}
...
}
myRepeater.DataBind();
....
The ItemDataBound event on the Repeater is being set to the
myRepeater_ItemDataBound and successfully executes once the DataBind
method is called.
protected void myRepeater_ItemDataBound(object source,
RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Header)
{
...
HtmlTableCell tdMyHeader =
(HtmlTableCell)e.Item.FindControl("tdMyHeader"); // Code stopped on
breakpoint here.
...
}
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
ListItemType.AlternatingItem)
{
bool didTheCodeStopHere = false; // Code DID NOT stop on
breakpoint here!?!
}
if (e.Item.ItemType == ListItemType.Footer)
{
bool didTheCodeStopHere = true; // Code stopped on breakpoint
here.
}
}
As the above comments state, the code stopped on the Header and Footer
breakpoints however did not stop on the Item/AlternatingItem
breakpoint. Also, when the code stopped on the header and footer
breakpoints I checked the ((DataView)source.DataSource).Count property
and it still contained two records.
Has anyone experience anything similar?
Thanks in advance,
J
I have a Repeater problem where the code within the <ItemTemplate> and
<AlternatingItemTemplate> tags are not being executed.
<asp:Repeater ID="myRepeater" Runat="server">
<HeaderTemplate>
<table cellspacing="0" cellpadding="0" border="0">
<tr>
<td ID="tdMyHeader" Runat="server">
...
</td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
...
<td><%# DataBinder.Eval(Container.DataItem,
"MyDateTime", "{0:h:mmtt}") %></td>
...
</tr>
</ItemTemplate>
<AlternatingItemTemplate>
<tr>
...
<td><%# DataBinder.Eval(Container.DataItem,
"MyDateTime", "{0:h:mmtt}") %></td>
...
</tr>
</AlternatingItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
The DataSource property on the Repeater is populated with a DataView
containing two records.
....
using (DataView dv = MyDataView())
{
if (dv != null && dv.Count > 0)
{
myRepeater.DataSource = dv;
}
...
}
myRepeater.DataBind();
....
The ItemDataBound event on the Repeater is being set to the
myRepeater_ItemDataBound and successfully executes once the DataBind
method is called.
protected void myRepeater_ItemDataBound(object source,
RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Header)
{
...
HtmlTableCell tdMyHeader =
(HtmlTableCell)e.Item.FindControl("tdMyHeader"); // Code stopped on
breakpoint here.
...
}
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
ListItemType.AlternatingItem)
{
bool didTheCodeStopHere = false; // Code DID NOT stop on
breakpoint here!?!
}
if (e.Item.ItemType == ListItemType.Footer)
{
bool didTheCodeStopHere = true; // Code stopped on breakpoint
here.
}
}
As the above comments state, the code stopped on the Header and Footer
breakpoints however did not stop on the Item/AlternatingItem
breakpoint. Also, when the code stopped on the header and footer
breakpoints I checked the ((DataView)source.DataSource).Count property
and it still contained two records.
Has anyone experience anything similar?
Thanks in advance,
J