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()
..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
>.
So your problem solved or not?
Yes. Problem solved. Thanks.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
0 comments:
Post a Comment