You must Sign In to post a response.
  • Category: ASP.NET

    Nested Datalist and coding


    I am wanting to use a nested datalist and I am using coding.

    The front end is, as follows:-
    <asp:DataList ID="DataList2" runat="server" DataKeyField="jobid" 
    <asp:Label ID="Label1" runat="server"
    Text='<%# Eval("title") %>'></asp:Label>
    <br />
    <br />
    <asp:DataList ID="DataList3" runat="server" DataSourceID="ObjectDataSource2">
    <asp:Label ID="Label2" runat="server" Text='<%# Eval("category") %>'></asp:Label>
    <asp:ObjectDataSource ID="ObjectDataSource2" runat="server"
    SelectMethod="get_jobs_category" TypeName="CL2.test_nested">
    <asp:ControlParameter ControlID="DataList2" Name="id"
    PropertyName="SelectedValue" Type="String" />
    <asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
    SelectMethod="get_all_jobs" TypeName="CL2.test_nested"></asp:ObjectDataSource>


    I have a class which is named as: "test_nested.vb" and this class is placed inside the App_Code folder. The code of this class, is, as follows:-
    Imports CL1.Class1
    Imports System.Data.SqlClient
    Imports Microsoft.VisualBasic

    Namespace CL2
    Public Class test_nested
    Public Shared Function get_all_jobs() As Object
    Dim da As New SqlDataAdapter("select * from jobs", con)
    Dim ds As New Data.DataSet
    da.Fill(ds, "all_jobs")
    Return ds
    End Function

    Public Shared Function get_jobs_category(ByVal id As String) As Object
    Dim da1 As New SqlDataAdapter("select [category] from jobs where [jobid]='" & id & "'", con)
    Dim ds1 As New Data.DataSet
    da1.Fill(ds1, "jobs_category")

    Return ds1
    End Function
    End Class
    End Namespace


    In this above mentioned class's code, I have imported another class, as: "Imports CL1.Class1". The purpose of the same, is to get the "con" connectionstring object which I have declared in the Class1.

    Now, what is happening, the outer datalist is showing all the required data, but the inner datalist is empty.

    Please let me know where the issue is.
  • #763543

    It is too difficult to analyse your code and say the problem, as a end user we don't know what it returns each object. Since you have a rights to check those, I suggest you to debug your code and verify the details whether it returns the proper details or not, if you got any errors please let us know so that we can help you better.

    Give respect to your work, Instead of trying to impress your boss.

    Blog :

  • Sign In to post your comments