DataList item not binding.

B

Barry

Hi,
I have a Datalist inside the ItemTemplate of another DataList. When I
drilldown, I'm not getting any data in either the itemtemplate or
headertemplate of the second DataList. I've confirmed that the
datasource is being populated properly, however the itemdatabound
event is not being fired. Here's some code:

<asp:datalist id="BatchList" runat="server"
repeatdirection="Vertical" headerstyle-cssclass="CategoryHeader"
alternatingitemstyle-cssclass="Content"
selecteditemstyle-cssclass="Selected" repeatcolumns="1" width="100%"
cellpadding="0" cellspacing="0" onitemcommand="BatchList_ItemCommand">
<headertemplate>
<table width="100%">
<tr>
Batches</tr>
<tr>
<td width="80px">Batch</td>
<td width="140px">Date</td>
<td width="80px">Material</td>
<td width="80px">Panels</td>
<td width="80px">Scrap</td>
<td width="80px">Yield</td>
</tr>
</table>
</headertemplate>
<itemtemplate>
<table border="0" cellpadding="5" cellspacing="0" width="100%"
cols="3">
<tr>
<td valign="top" width="80px">
<asp:linkbutton id="Batch" runat="server" Text='<%#
DataBinder.Eval(Container.DataItem, "Batch") %>' CommandName="select"
/></td>
<td width="150px">
<asp:label id="ProductionDate" runat="server" Text='<%#
DataBinder.Eval(Container.DataItem, "ProductionDate") %>' Visible=True
/></td>
<td width="80px">
<asp:label id="Material" runat="server" Text='<%#
DataBinder.Eval(Container.DataItem, "Material") %>' Visible=True />
</td>
<td width="80px">
<asp:label id="Panels" runat="server" Text='<%#
DataBinder.Eval(Container.DataItem, "Panels") %>' Visible=True />
</td>
<td width="80px">
<asp:label id="ScrapQuantity" runat="server" Text='<%#
DataBinder.Eval(Container.DataItem, "ScrapQuantity") %>' Visible=True
/>
</td>
<td width="80px" align="right">
<asp:label id="Yield" runat="server" Text='<%#
DataBinder.Eval(Container.DataItem, "Yield") %>' Visible=True />
</td>
</tr>
</table>
</itemtemplate>
<selecteditemtemplate>
<table border="0" cellpadding="5" cellspacing="0" width="100%">
<tr>
<td valign="top" class="Content" width="80px">
<%# DataBinder.Eval(Container.DataItem, "Batch") %>
</td>
<td width="155px" class="Content">
<asp:label id="Label1" runat="server" Text='<%#
DataBinder.Eval(Container.DataItem, "ProductionDate") %>' Visible=True
/></td>
<td width="80px" class="Content">
<asp:label id="Label10" runat="server" Text='<%#
DataBinder.Eval(Container.DataItem, "Material") %>' Visible=True />
</td>
<td width="80px" class="Content">
<asp:label id="Label11" runat="server" Text='<%#
DataBinder.Eval(Container.DataItem, "Panels") %>' Visible=True />
</td>
<td width="80px" class="Content">
<asp:label id="Label12" runat="server" Text='<%#
DataBinder.Eval(Container.DataItem, "ScrapQuantity") %>' Visible=True
/>
</td>
<td width="80px" align="right" class="Content">
<asp:label id="Label13" runat="server" Text='<%#
DataBinder.Eval(Container.DataItem, "Yield") %>' Visible=True />
</td>
</tr>
<tr>
<td>
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td valign="top" class="OrderID">
<img src="images/spacer.gif" width="20" height="1">
</td>
<td>

<asp:datalist BorderWidth="3" id="BatchDetail" runat="server"
DataSource='<%# GetBatchDetail(DataBinder.Eval(Container.DataItem,
"Batch")) %>' OnItemDataBound="DebugBatchList"
RepeatDirection="Vertical" repeatcolumns="0" Width="100%"
CellPadding="0" cellspacing="0"
OnItemCommand="BatchDetail_ItemCommand" BorderColor="#ff0033"
Visible="true" ShowHeader="True" Enabled="True" GridLines="Both">
<itemtemplate>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td width="100">
<asp:linkbutton id="Linkbutton1" runat="server" Text='<%#
DataBinder.Eval(Container.DataItem, "AestheticBatch") %>'
CommandName="select" />
</td>
<td width="200">
<asp:label id="Label6" runat="server" Text='<%#
string.Format("{0:d}", DataBinder.Eval(Container.DataItem,
"BackBatch")) %>'/>
</td>
<td>
<asp:label id="Label7" runat="server" Text='<%#
string.Format("{0:d}", DataBinder.Eval(Container.DataItem,
"BackLength")) %>' />
</td>
</tr>
</table>
</itemtemplate>

Protected Sub BatchDetail_ItemCommand(ByVal Sender As Object,
ByVal e As DataListCommandEventArgs)
' change the selected index of Orders Datalist
Dim cmd As String = CType(e.CommandSource,
LinkButton).CommandName
Dim senderlist As DataList = CType(Sender, DataList)
If cmd = "select" Then
senderlist.SelectedIndex = e.Item.ItemIndex
End If
' re-bind to display orders info with new selected index.
senderlist.DataSource =
GetBatchDetail(CStr(ViewState(_batch)))
senderlist.DataBind()
End Sub

Protected Function GetBatchDetail(ByVal batch As Int32) As
TechStyle.Reports.Components.DrillDownReportCollection
If batch = 0 Then
batch = CStr(ViewState(_batch))
End If
Return TechStyle.Reports.Components.DrillDownReport.GetBatchDetail(batch)
End Function

Public Sub DebugBatchList(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataListItemEventArgs)
Trace.Warn("DebugBatchList", "BatchList datasource: " &
Me.BatchList.DataSource.ToString)
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top