Populating ddl list from sql db in order

chipprz

New member
Joined
Apr 10, 2006
Messages
2
Programming Experience
Beginner
Hello all. I have recently started to support a project at work and I am not very good at vb. I have a ddl ('ddlOrderNumber') that is being populated from a sql db. When the ddl is accessed on the web form the numbers are not in numerical order. How can I get these in numerical order? Here is a sample of the code:
Protected Sub ddlOrderNumber_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlOrderNumber.SelectedIndexChanged

clearform()
ddlLevel.Items.Clear() ''empty ddl
Panel3.Visible = False
hf_Panel3Visible.Value = "notVisible"
Panel1.Visible = False
lblInformation.Text = ""
lblCustomer.Text = ""
If ddlOrderNumber.SelectedIndex > 0 Then ''0 is <<pick...>>
Panel1.Visible = True
Else

Exit Sub
End If

Is there something I can put in here? Or am I looking in the wrong spot?
Any help would be greatly appreciated.
Thanks, Crystal
 
Hello all. I have recently started to support a project at work and I am not very good at vb.
I dont envy you.

I have a ddl ('ddlOrderNumber') that is being populated from a sql db. When the ddl is accessed on the web form the numbers are not in numerical order. How can I get these in numerical order?
Depends what you mean by ddl. I think of it as "data definition language" - a subset of SQL that is used for altering the dataase structure. i doubt it means the same here..

What's a ddl?
 
You say it is being populated from a database?

can i assume there is an SQL query somewhere, SELECT * From table etc?

If so find this query (in your code or your DataSet depending on how your project works) and affix 'ORDER by number ASC'

Example:

VB.NET:
Select * From Table Order By NumberID ASC

This will retrieve from the database in a specific ascending order, use DESC for the opposite.

Obviously Change NumberID to the field you want to order by.

Good Luck :D

Regards

HC.
 
Back
Top