|
-
Oct 19th, 2005, 03:33 PM
#1
Thread Starter
Fanatic Member
[RESOLVED] dropdownlist SelectionChange
I have some constant arraylists that are filled when a dropdownlist value is changed (based on the value of the DDL). When the first DDL is changed, I have a second DDL that binds to the values of the constant arraylist. However I ran the code and change the value of the ddl but it doesn't databind to the second DDL. Do I have to refresh the page? And if so how can I tell it to keep the selectedvalue of the first dropdownlist that was fires the SelectedIndexChanged event?
VB Code:
Private Sub ddlSection_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlSection.SelectedIndexChanged
If ddlSection.SelectedItem.Text = "500" Then 'this is the first ddl
'Section500
arrSection500.Clear()
arrSection500.Add("Select Form")
arrSection500.Add("500-10")
arrSection500.Add("500-10C")
arrSection500.Add("500-11")
ddlForm.DataSource = arrSection500 'this is the second ddl i want to bind this arraylist to
ddlForm.DataBind()
End If
THanks again!!
Last edited by drpcken; Oct 21st, 2005 at 05:55 PM.
-
Oct 19th, 2005, 04:49 PM
#2
Re: dropdownlist SelectionChange
I write in C#, not VB, so the code is slightly different, but my event contains the following code and executes perfectly:
VB Code:
System.Collections.ArrayList oAL = new ArrayList(0);
oAL.Add("== Please Choose ==");
oAL.Add("500-10");
oAL.Add("500-10C");
oAL.Add("500-11");
ddlForm.DataSource = oAL;
ddlForm.DataBind();
Need to re-register ASP.NET?
C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i
(Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)
-
Oct 19th, 2005, 05:42 PM
#3
Thread Starter
Fanatic Member
Re: dropdownlist SelectionChange
aah thanks!
another problem I'm having is I need my dropdownlist to be the value of a parameter in the url if the parameter exists, but it doesn't seem to work. Here's my code
VB Code:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If Not IsPostBack Then
If Request.QueryString("section") = "" Then
ddlSection.SelectedIndex = -1
Else
ddlSection.SelectedItem.Value = Request.QueryString("section")
End If
End If
End Sub
Right now when the parameter equals something, my ddl still goes to my default value and not my value of my parameter.
-
Oct 20th, 2005, 08:57 AM
#4
New Member
Re: dropdownlist SelectionChange
foreach x as listitem in ddlSection.items
if x.Value = Request.QueryString("section") then
x.selected=true
exit for
endif
next
Just because you're paranoid doesn't mean they aren't out to get you
Quidquid latine dictum sit, altum viditur
-
Oct 21st, 2005, 05:55 PM
#5
Thread Starter
Fanatic Member
Re: dropdownlist SelectionChange
Thanks for the suggestion, what I did though was set AUTOPOSTBACK on and when it loads it grabs its value i was setting the parameter as from a different control
Thanks for all the help!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|