troubleshooting Question

Binding a Datatable to a datalist

Avatar of TheWebGuy38
TheWebGuy38 asked on
.NET ProgrammingASP.NETVisual Basic.NET
5 Comments1 Solution364 ViewsLast Modified:
I did this a long time ago for testing purposes but I can't remember what I did.

all I want to do is bind a datatable to a datalist.

If i recall, I had to fill the datatable or pass it into a dataset before putting it in the datalist.
this is my code which is not filling the datalist

any help appreciated

 Dim Dt As DataTable = New DataTable("Table")

        Dim Title As DataColumn = New DataColumn("Title", GetType(String))
        Dim Picture As DataColumn = New DataColumn("Picture", GetType(String))

        '-- Add Data Column to DataTable --//
        Dt.Columns.Add(Title)
        Dt.Columns.Add(Picture)

        '-- Add Data Rows to DataTable --//
        Dim Dr1 As DataRow = Dt.NewRow
        Dr1("Picture") = "Images/C.jpg"
        Dr1("Title") = "Pic 1"

        Dim Dr2 As DataRow = Dt.NewRow
        Dr2("Picture") = "Images/d.jpg"
        Dr2("Title") = "Pic 2"

        Dim Dr3 As DataRow = Dt.NewRow
        Dr3("Picture") = "Images/4potsandacup.jpg"
        Dr3("Title") = "Pic 3"

     
        Dt.Rows.Add(Dr1)
        Dt.Rows.Add(Dr2)
        Dt.Rows.Add(Dr3)


        DataList1.DataSource = Dt
        DataList1.DataBind()
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 5 Comments.
Join the Community
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 5 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