By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,391 Members | 1,387 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,391 IT Pros & Developers. It's quick & easy.

Populating DataList control

P: n/a
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

Nov 18 '05 #1
Share this Question
Share on Google+
3 Replies

P: n/a
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.



-----Original Message-----
Hi, Jerry

From your code, I guess you are dynamically generating datalist.However, I don't see any code to add the datalist to the page.You need to add:

Bin Song, MCP

Nov 18 '05 #2

P: n/a
So your problem solved or not?
Nov 18 '05 #3

P: n/a

Yes. Problem solved. Thanks.
*** Sent via Developersdex ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.