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
 [RESOLVED] Changing Dropdownlists Bound To Data

Author  Topic 

Billkamm
Posting Yak Master

124 Posts

Posted - 2006-01-10 : 14:10:23
Hi, I have a dropdownlist control that is bound to a dataset. For example:

DataTextField would be a name of a region
DataValueField would be the region ID number (key in the database)

Anyway I fill this dropdownlist with all the possible values and they I run a query to obtain what the document already has. The problem I have is how to I change the dropdownlist?

Example:
Florida 3
Georgia 9
Texas 34

Florida will show up first, but on the current document it might be Texas. I'm pulling the value "34" from my query. How can I update this dropdownlist to display Texas?

jhermiz

3564 Posts

Posted - 2006-01-10 : 14:28:41
Hi not sure if you are using C# or VB.net but here:


Dim f As Functions
Try
f = New Functions
Me.ddlClient.Items.Clear()
f.LoadClients(ddlClient)
ddlClient.Items.Insert(0, New ListItem("All Clients", "-1"))
Me.ddlClient.Items.FindByValue(CType(intClientID, String)).Selected = True
Me.ddlMyTickets.Items.Clear()
f.LoadMyTickets(Me.ddlMyTickets, lngLoginID)
ddlMyTickets.Items.Insert(0, New ListItem(" ", "-1"))
Catch ex As Exception
Response.Write("An Error Occurred: " & ex.ToString())
Finally
f = Nothing
End Try




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

Billkamm
Posting Yak Master

124 Posts

Posted - 2006-01-10 : 14:35:36
Thank you! :)
Go to Top of Page
   

- Advertisement -