Populating DataList control

J

Jerry Higgins

I have a datalist control on a web page and I am trying
to populate it through the page_load event.

The name of the control on the web page is "MyList".

I had code behind a button click to populate it and that
worked. Now that I've moved the code to the page_load
event it is not working. I suspect that "MyList" on the
page doesn't know about "MyList" in the page_load code
but I don't know how to connect the two. Any help would
be appreciated.

Here is the code


Dim DS As DataSet
Dim MyConnection As SqlConnection

Dim MyCommand As SqlDataAdapter
Dim MyList As DataList

MyConnection = New SqlConnection
("server=x2;database=Orders;Trusted_Connection=yes")
MyCommand = New SqlDataAdapter("select
ReferenceNO, Loc from Request", MyConnection)

DS = New DataSet
MyCommand.Fill(DS, "Request")

MyList = New DataList
MyList.DataSource = DS.Tables
("Request").DefaultView

MyList.DataBind()
..
 
J

Jerry Higgins

Hi Bin,

I had added the DataList control from the toolbox. My
problem was that I had failed to add the

<%# DataBinder.Eval(Container.DataItem, "ReferenceNO") %>

inside the <td> tags in the control.

Thanks,

Jerry
 

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

Top