troubleshooting Question

Databinding on Nested Listview

Avatar of ameek
ameekFlag for United States of America asked on
.NET ProgrammingASP.NET
7 Comments1 Solution880 ViewsLast Modified:
Hello,

Am having a hard time passing the parameters through on this nested listview.   I need to bind the child MaterialsList listview to data in the parent TicketList listview by the End Code.   The job number is passed through with a QueryStringParameter and this is working fine.

ASP and code behind I am using is included below.   I am getting the following error:  Compiler Error Message: BC30506: Handles clause requires a WithEvents variable defined in the containing type or one of its base types.

Help on either fixing this error or a better method to filter the child table by the End_Code in the parent table would be much appreciated!
<asp:SqlDataSource ID="Ticket" runat="server" 
        ConnectionString="<%$ ConnectionStrings:Ticket %>" 
        SelectCommand="SELECT [Job_Number], [End_Code] 
        FROM [Ticket_Main]">
<SelectParameters>
       <asp:QueryStringParameter Name="Job_Number" QueryStringField="Job_Number"  Type="String" />
                </SelectParameters>
</asp:SqlDataSource>

    
    <asp:SqlDataSource ID="Materials" runat="server" 
                ConnectionString="<%$ ConnectionStrings:Ticket %>" 
                SelectCommand="SELECT * FROM [Materials_Main] 
                WHERE  End_Code = @End_Code">
                <SelectParameters>  
                <asp:QueryStringParameter Name="Job_Number"             QueryStringField="Job_Number"  Type="String" />
                <asp:ControlParameter Name="End_Code" ControlID="End_CodeLabel" PropertyName="String"  />
               </SelectParameters>
   
            </asp:SqlDataSource>



    <asp:ListView ID="TicketList" runat="server" DataKeyNames="Job_Number, End_Code" 
        DataSourceID="Ticket">
        <ItemTemplate>
            <asp:Label ID="Job_NumberLabel" runat="server" Text='<%# Eval("Job_Number") %>' />
             -<asp:Label ID="End_CodeLabel" runat="server" Text='<%# Eval("End_Code") %>' />
            
            <asp:ListView ID="MaterialsList" runat="server" DataSourceID="Materials" 
        DataKeyNames="Material_Index">
            <ItemTemplate>
                <tr>
                    <td>
                    <asp:Label ID="Material_IndexLabel" runat="server" 
                    Text='<%# Eval("Material_Index") %>' />
                    </td>
                    <td>
                        <asp:Label ID="Job_NumberLabel" runat="server" 
                            Text='<%# Eval("Job_Number") %>' />
                    </td>
                    <td>
                        <asp:Label ID="End_CodeLabel" runat="server" Text='<%# Eval("End_Code") %>' />
                    </td>
                    <td>
                        <asp:Label ID="Part_NumberLabel" runat="server" 
                            Text='<%# Eval("Part_Number") %>' />
                    </td>
                    <td>
                        <asp:Label ID="Material_NameLabel" runat="server" 
                            Text='<%# Eval("Material_Name") %>' />
                    </td>
                </tr>
            </ItemTemplate>
            <LayoutTemplate>
                <table id="Table2" runat="server">
                    <tr id="Tr1" runat="server">
                     <td id="Td1" runat="server">
                        <table ID="itemPlaceholderContainer" runat="server" border="0" style="">
                            <tr id="Tr2" runat="server" style="">
                                <th id="Th1" runat="server">
                                Material_Index</th>
                                <th id="Th2" runat="server">
                                Job_Number</th>
                                <th id="Th3" runat="server">
                                End_Code</th>
                                <th id="Th4" runat="server">
                                Part_Number</th>
                                <th id="Th5" runat="server">
                                Material_Name</th>
                            </tr>
                            <tr ID="itemPlaceholder" runat="server">
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr id="Tr3" runat="server">
                    <td id="Td2" runat="server" style="">
                        <asp:DataPager ID="DataPager1" runat="server">
                            <Fields>
                                <asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True" 
                                ShowLastPageButton="True" />
                            </Fields>
                        </asp:DataPager>
                    </td>
                </tr>
            </table>
        </LayoutTemplate>
            </asp:ListView>
            <br />
            <br />
        </ItemTemplate>
        <LayoutTemplate>
            <div ID="itemPlaceholderContainer" runat="server" style="">
                <span ID="itemPlaceholder" runat="server" />
            </div>
            <div style="">
                <asp:DataPager ID="DataPager1" runat="server" PageSize="25">
                    <Fields>
                        <asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True" 
                            ShowLastPageButton="True" />
                    </Fields>
                </asp:DataPager>
            </div>
        </LayoutTemplate>
    
    
    </asp:ListView>







code behind:

Protected Sub TicketList_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.ListViewItemEventArgs) Handles ListView1.ItemDataBound


        If e.Item.ItemType = ListViewItemType.DataItem Then
            TicketList.Items.Clear()
            Materials.SelectParameters("End_Code").DefaultValue = DirectCast(e.Item.FindControl("End_CodeLabel"), Label).Text
        End If

    End Sub
ASKER CERTIFIED SOLUTION
ddayx10

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 7 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros