Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DropDownList and SelectedIndexChanged

Status
Not open for further replies.

KidHoss

Programmer
May 22, 2000
27
US
I have a DropDownList bound to a dataset that provides the value and text fields. If the select statement only returns one entry, how can I trigger the SelectedIndexChanged event even if there is only one entry in the dataset? The selection of an entry in this DropDownList causes another select to be executed and another DropDownList be filled with data from the next select. But I cannot trigger the event because there is only one entry in the previous DropDownList.
 
The selected index change event should reference a function...

then, when you're binding your dataset, do a check for rows..
Code:
if ds.tables(0).rows = 1 then
   call function
end if

post some of your code if this doesn't make sense.
 
Thanks for the idea.... but let me ask it this way. What if I want to select the first item in the dropdownlist? Since it is the same item the dropdownlist starts out showing ...... the selectedindexchange event does not fire because the selected index does not change. How do you deal with this?
 
that's what i'm saying...have a function to do either...

Code:
private sub bindddl
 if ds.tables(0).rows = 1 then
   ddlbindevent
 end if
end sub

private sub ddlbindevent
  dim i as integer
  i = cint(ddl.selecteditem.value)
  'do whatever you need to do with this.....
end sub

Private Sub ddl_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ddl.SelectedIndexChanged
   ddlbindevent    
End Sub

??? Web Hosting Solutions[/LINK]

??? [url=http://www.suaffiliates.net]Affiliate Program[/LINK]

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top