Dropdownlist not working

B

Binod Nair

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.AppSettings("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
 
I

IbrahimMalluf

Hello Binod


Populate the the Dropdown list in the Code Behind page, not on the HTML
side. Create a procedure that handles the populating of the dropdownlist
then call it from wherever you need it.


Protected Sub LoadDropDown()

Dim MyDataSet as DataSet

MyDatSet = GetUsers()

With DataList1
.DataSource=MyDataSet.Tables(0)
.DataValueField="UserID"
.DataTextField="User_Email"
End With
End Sub



--
Ibrahim Malluf
http://www.malluf.com
==============================================
MCS Data Services Code Generator
http://64.78.34.175/mcsnet/DSCG/Announcement.aspx
==============================================
Pocket PC Return On Investment Calculator
Free Download http://64.78.34.175/mcsnet/kwickKalk1.aspx
 

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