DataList item not binding.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Barry

    DataList item not binding.

    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="Categ oryHeader"
    alternatingitem style-cssclass="Conte nt"
    selecteditemsty le-cssclass="Selec ted" repeatcolumns=" 1" width="100%"
    cellpadding="0" cellspacing="0" onitemcommand=" BatchList_ItemC ommand">
    <headertemplate >
    <table width="100%">
    <tr>
    Batches</tr>
    <tr>
    <td width="80px">Ba tch</td>
    <td width="140px">D ate</td>
    <td width="80px">Ma terial</td>
    <td width="80px">Pa nels</td>
    <td width="80px">Sc rap</td>
    <td width="80px">Yi eld</td>
    </tr>
    </table>
    </headertemplate>
    <itemtemplate >
    <table border="0" cellpadding="5" cellspacing="0" width="100%"
    cols="3">
    <tr>
    <td valign="top" width="80px">
    <asp:linkbutt on id="Batch" runat="server" Text='<%#
    DataBinder.Eval (Container.Data Item, "Batch") %>' CommandName="se lect"
    /></td>
    <td width="150px">
    <asp:label id="ProductionD ate" runat="server" Text='<%#
    DataBinder.Eval (Container.Data Item, "ProductionDate ") %>' Visible=True
    /></td>
    <td width="80px">
    <asp:label id="Material" runat="server" Text='<%#
    DataBinder.Eval (Container.Data Item, "Material") %>' Visible=True />
    </td>
    <td width="80px">
    <asp:label id="Panels" runat="server" Text='<%#
    DataBinder.Eval (Container.Data Item, "Panels") %>' Visible=True />
    </td>
    <td width="80px">
    <asp:label id="ScrapQuanti ty" runat="server" Text='<%#
    DataBinder.Eval (Container.Data Item, "ScrapQuantity" ) %>' Visible=True
    />
    </td>
    <td width="80px" align="right">
    <asp:label id="Yield" runat="server" Text='<%#
    DataBinder.Eval (Container.Data Item, "Yield") %>' Visible=True />
    </td>
    </tr>
    </table>
    </itemtemplate>
    <selecteditemte mplate>
    <table border="0" cellpadding="5" cellspacing="0" width="100%">
    <tr>
    <td valign="top" class="Content" width="80px">
    <%# DataBinder.Eval (Container.Data Item, "Batch") %>
    </td>
    <td width="155px" class="Content" >
    <asp:label id="Label1" runat="server" Text='<%#
    DataBinder.Eval (Container.Data Item, "ProductionDate ") %>' Visible=True
    /></td>
    <td width="80px" class="Content" >
    <asp:label id="Label10" runat="server" Text='<%#
    DataBinder.Eval (Container.Data Item, "Material") %>' Visible=True />
    </td>
    <td width="80px" class="Content" >
    <asp:label id="Label11" runat="server" Text='<%#
    DataBinder.Eval (Container.Data Item, "Panels") %>' Visible=True />
    </td>
    <td width="80px" class="Content" >
    <asp:label id="Label12" runat="server" Text='<%#
    DataBinder.Eval (Container.Data Item, "ScrapQuantity" ) %>' Visible=True
    />
    </td>
    <td width="80px" align="right" class="Content" >
    <asp:label id="Label13" runat="server" Text='<%#
    DataBinder.Eval (Container.Data Item, "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.Data Item,
    "Batch")) %>' OnItemDataBound ="DebugBatchLis t"
    RepeatDirection ="Vertical" repeatcolumns=" 0" Width="100%"
    CellPadding="0" cellspacing="0"
    OnItemCommand=" BatchDetail_Ite mCommand" BorderColor="#f f0033"
    Visible="true" ShowHeader="Tru e" Enabled="True" GridLines="Both ">
    <itemtemplate >
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
    <tr>
    <td width="100">
    <asp:linkbutt on id="Linkbutton1 " runat="server" Text='<%#
    DataBinder.Eval (Container.Data Item, "AestheticBatch ") %>'
    CommandName="se lect" />
    </td>
    <td width="200">
    <asp:label id="Label6" runat="server" Text='<%#
    string.Format(" {0:d}", DataBinder.Eval (Container.Data Item,
    "BackBatch" )) %>'/>
    </td>
    <td>
    <asp:label id="Label7" runat="server" Text='<%#
    string.Format(" {0:d}", DataBinder.Eval (Container.Data Item,
    "BackLength ")) %>' />
    </td>
    </tr>
    </table>
    </itemtemplate>

    Protected Sub BatchDetail_Ite mCommand(ByVal Sender As Object,
    ByVal e As DataListCommand EventArgs)
    ' change the selected index of Orders Datalist
    Dim cmd As String = CType(e.Command Source,
    LinkButton).Com mandName
    Dim senderlist As DataList = CType(Sender, DataList)
    If cmd = "select" Then
    senderlist.Sele ctedIndex = e.Item.ItemInde x
    End If
    ' re-bind to display orders info with new selected index.
    senderlist.Data Source =
    GetBatchDetail( CStr(ViewState( _batch)))
    senderlist.Data Bind()
    End Sub

    Protected Function GetBatchDetail( ByVal batch As Int32) As
    TechStyle.Repor ts.Components.D rillDownReportC ollection
    If batch = 0 Then
    batch = CStr(ViewState( _batch))
    End If
    Return TechStyle.Repor ts.Components.D rillDownReport. GetBatchDetail( batch)
    End Function

    Public Sub DebugBatchList( ByVal sender As Object, ByVal e As
    System.Web.UI.W ebControls.Data ListItemEventAr gs)
    Trace.Warn("Deb ugBatchList", "BatchList datasource: " &
    Me.BatchList.Da taSource.ToStri ng)
    End Sub
Working...