I never have liked binding data using <%# %>, because it sure looks old
asp'ey to me. So I'll tell you how I would do it. I've never seen that
SqlHelper object either, but I'll assume it is returning a valid dataset.
in your page_load, (or anywhere else really)
add this
DropDownList1.dataSource = GetUsers()
DropDownList1.DataTextField = "user_email"
DropDownList1.DataValueField = "user_id"
DropDownList1.DataBind()
then in your aspx file, where you want the DropDown you can just put
<asp:DropDownList id="DropDownList1" runat="server" />
where you want the dropdown.
and it should work.
Another thing too, depending on what you are doing, you may want to just use
a sqldatareader to populate this box, instead of passing around a dataset,
especially if you have no intention of ever editing the items in the box.
--Michael
"Binod Nair" <na*******@hotmail.com> wrote in message
news:eu**************@TK2MSFTNGP10.phx.gbl...
Hi All,
This is what I am trying to do.I have an aspx page with the the following
code block.
<asp:DropDownList id="DropDownList1" runat="server" DataSource="<%#
GetUsers%>" DataTextField="user_email" DataValueField="user_id">
</asp:DropDownList>
GetUsers is defined in the .vb file
Public Function GetUsers() As DataSet
Dim ds As DataSet
ds =
SqlHelper.ExecuteDataset(ConfigurationSettings.App Settings("ConnectionString "), CommandType.Text, "select user_id , user_email from users")
Return ds
End Function
I am kind of frustrated that I cannot make this thing work.What am I doing
wrong ?
--binod