473,466 Members | 1,443 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Populating DataList control

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()
..
Nov 18 '05 #1
3 1732
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

-----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:
Page.Controls.Add(MyList)

Bin Song, MCP
.

Nov 18 '05 #2
So your problem solved or not?
Nov 18 '05 #3

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

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Chris Leuty | last post by:
I am populating a multiselect Listbox from a dataset, with the content of the listbox filled by one table, and the selections determined from another table. So far, I have been keeping the dataset...
1
by: msnews.microsoft.com | last post by:
I'd like to hear your thoughts on best methods for populating drop down list controls. I have states and countries drop down lists that don't change often, so naturally I "hard code" them in the...
10
by: Bharat | last post by:
Hi Folks, Suppose I have two link button on a page (say lnkBtn1 and lnkBtn2). On the click event of the lnkbtn1 I have to add a dynamically created control. And On the click event of the lnkBtn2 I...
6
by: tshad | last post by:
I need to get to a status label I have on my footer section of my datalist. There is no event happening that would go to the footer. I am just doing some processing and want to update the label...
4
by: Patrick.O.Ige | last post by:
I have a CheckBoxList in a DataList and i'm trying to get item Selected after doing a postBack. I have set my CheckBoxlist AutoPostBack="True" Any ideas what 'm doing wrong? It seems not to...
2
by: Hans Merkl | last post by:
Hi, I am trying to use a user control as EditItemTemplate in a DataList. It loads fine but I can't figure out how to bind to the data of the DataList. Here is what I have got so far: ...
6
by: Victor | last post by:
Hi. all I have a customize web control. I have three simple properties and customized render class. then I add this control into my datalist like <asp:DataList ID="datalist" runat="server"...
4
by: Peter | last post by:
I have a DataList and each item in the datalist has an imge, I want to change the datalist item image on the client side when user clicks a button. How would I do that with JavaScript, does anyone...
0
by: Hamayun Khan | last post by:
Hi I want to populate the Datalist control from some data using code below <asp:DataList Width="100%" ID="DataList2" runat="server" DataSourceID="SqlDataSource2" RepeatDirection=horizontal...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.