Last post Apr 09, 2011 04:36 AM by as7685
Jan 04, 2007 10:52 AM|defyant_2004|LINK
I have an ASP.NET 2.0 that contains a dropdown list used to filter records based on a group number.
For example, if the dropdown list selectedvalue = 3, only records containing a 3 in the group number column of the table will display.
This is working perfectly. However, when the page first displays the default value is 1, and the records from group 1 do NOT display unless I trigger the dropdown list event.
I am trying to get the records to display for group 1 when the page first opens to avoid having to use the dropdown when the page loads.
The “drop down list control” filters records in a “data list” control.
I am thinking of writing a piece of VB.NET code to automatically call the Drop Down List’s SelectIndexChanged event on the page so the user does not have to do it.
My question is, how do I call that event from the “On Page Load”
or, is there a better way to do this?
Thanks very much for any help with this.
Jan 04, 2007 02:26 PM|DarrellNorton|LINK
Just make a call to the dropdownlist's method in the Page_Load:
myDropDownList_SelectedIndexChanged( this, EventArgs.Empty )
Jan 04, 2007 03:43 PM|defyant_2004|LINK
Let me rephrase this:
I want the click event of “Button1” to “TRIGGER” the action of a user selecting a value from the dropdown list and firing the code behind the dropdown.
This particular event will trigger the dropdown to select the value = 1 and fire the code behind.
Does that make sense?
Thank you very much.
Jan 04, 2007 04:01 PM|defyant_2004|LINK
Actually, I think I need to call and additional post back to “refresh the page” .
That is what I think I am looking for. Can I tell the page to do a “double postback”?
Jan 04, 2007 04:11 PM|defyant_2004|LINK
I am not sure what the best solution is.
I just want the records to show up on the first load of the page without having to do the extra action of selecting from the dropdownlist.
The default value is 1, but I have to select the value from the list and cause a postback for the filtered records to appear the first time the page is loaded.
Anytime after the first load is fine, just that first load is coming up empty.
Jan 07, 2007 05:51 PM|mokeefe|LINK
As per Darrell’s earlier post.
Protected Sub Page_Load(ByVal sender
ByVal e As System.EventArgs)
' Where the DropDownlist ID is DropDownList1
Me.DropDownList1.SelectedValue = 3
' Calls the method directly passing the appropriate sender
Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender
ByVal e As System.EventArgs)
' presuming you get your data here by the selected index - provided for breakpoint only (remove)
Dim index As
Integer = Me.DropDownList1.SelectedIndex
Jan 16, 2008 11:04 AM|iumer|LINK
i want to add evnet for dropdownlist in asp.net ( vb.net )
when i use addhandler then i can tsee my dropdownlist ? its set to run at server, other than addhandler i can see cmbmydropdown?plz help me
Oct 19, 2010 02:27 PM|hinu39|LINK
i have tried this in my application but it doesnt work.
in my application i have first dropdown box which gets filled using sqldatasource and according to value in that the second dropdown box gets filled using in DropdownBox1_SelectedIndexChanged event, and in the DropDownBox2_SelectedIndexChanged event other
textboxs gets filled,
all i want is when the page loads for the first time when the selected index of the first dropdownbox is 0 the rest controlls get filled automatically but somehow its not working for me, i have tried adding DropdownList1_SelectedIndexChanged(sender, e) in
the Page_Load event and also try to set the selected Index for the dropdown list in the page load but none of these working, please help, guide me through this.
Thank you so much.
Jan 20, 2011 12:21 PM|hinu39|LINK
finally done with this.
Apr 09, 2011 04:36 AM|as7685|LINK
if possible if you could share your solution please