Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 Binding DropDownList

Author  Topic 

reflex2dotnet
Yak Posting Veteran

99 Posts

Posted - 2007-02-16 : 10:29:52
Hi everybody

In my application, i want to bind a dropdownlist in page load.
The problem is that, in result, the dropdowmlisst shows
r
r
2
3
whiich is the first data in my result set rr23

Code i am using is
Sub BindModelNumbers(ByRef accountID As Int32, ByRef contactID As Int32)

Dim modelBLL As BLL = New BLL
Dim dsAllModels As DataSet
dsAllModels = modelBLL.GetAllModles(accountID, contactID)
ddlModelSelect.DataSource = dsAllModels.Tables(0).Rows(0)("Model Number").ToString
ddlModelSelect.DataTextField = "Model Number"

ddlModelSelect.DataBind()

the result set has the data of type
ModelNumber ID
rr23 --- 6
5gr3 --- 24

can anyone please help me to figure it out
I want to display
rr23
5gr3
...
...

Now displaying
r
r
2
3

Thanks

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2007-02-16 : 10:55:24
quote:

ddlModelSelect.DataSource = dsAllModels.Tables(0).Rows(0)("Model Number").ToString



You are binding to a particular row in the table; you need to bind to the entire table:

ddlModelSelect.DataSource = dsAllModels.Tables(0)

- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page

reflex2dotnet
Yak Posting Veteran

99 Posts

Posted - 2007-02-16 : 10:57:51
Thanks.
I got it worked
Go to Top of Page

jhermiz

3564 Posts

Posted - 2007-02-16 : 13:50:27
Just an FYI, might be a good idea to name your datasets as well, that way you avoid any issues remembering exactly how to reference it.

Just a suggestion :).


Keeping the web experience alive -- [url]http://www.web-impulse.com[/url]

RS Blog -- [url]http://weblogs.sqlteam.com/jhermiz[/url]
Go to Top of Page
   

- Advertisement -