473,388 Members | 1,340 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

reset selected index on droplist

TJS
After a post back the selected index should be rest in a droplist to match
user's choice, but page always show selected item as first one in the
droplist.

How can iforce the selected item to be reset

I have:

Sub Page_Load(s As Object, e As EventArgs)
If Page.IsPostBack then
If len( request.params("idx")) then vSelectedItem =
request.params("idx")
SearchList.SelectedIndex= vSelectedItem
End if
end sub
Sub ApplyFilter_Click(s As Object, e As EventArgs)
Dim vSelectedItem As String
vSelectedItem = SearchList.SelectedIndex
response.redirect("Editor.aspx?idx=" & vSelectedItem)
End Sub

Nov 19 '05 #1
4 1362
Use:

SearchList.SelectedIndex = -1;
--
Cheers,
Gaurav Vaish
http://www.mastergaurav.org
http://mastergaurav.blogspot.com
----------------------

Nov 19 '05 #2
TJS
if I manually hard code a value into the selectedindex, then the droplist
reselects correctly . But the problem appears to be the index of the user
selection is always returned as zero in ApplyFilter_Click. any idea why ?

Sub ApplyFilter_Click(s As Object, e As EventArgs)
Dim vSelectedItem As String
vSelectedItem = SearchList.SelectedIndex
response.redirect("Editor.aspx?idx=" & vSelectedItem)
End Sub

........
<asp:DropDownList
id="SearchList"
AutoPostBack="False"
runat="server" cssClass="">
</asp:DropDownList>

<asp:Button id="SearchButton"
onclick="ApplyFilter_Click"
runat="server"
Text="GO">
</asp:Button>
================sample html output ================
<select name="SearchList" id="SearchList">
<option value="59">test1 </option>
<option value="60">test2 </option>
<option value="61">test3 </option>
</select>

Nov 19 '05 #3
So, you get SearchList.SelectedIndex = 0 always?

What all other event-handlers do you have for the page? The situtation
is highly unlikely.

What version of ASP.Net (with SP) are you using? If you've applied SP
1, try reinstalling the javascript files. You can do this by:

%WINDIR%\Microsoft.Net\Framework\v1.1.4322\aspnet_ regiis -c
--
Cheers,
Gaurav Vaish
http://www.mastergaurav.org
http://mastergaurav.blogspot.com
----------------------

Nov 19 '05 #4
TJS
I changed my code to be

ID = Int32.Parse(SearchList.SelectedItem.Value)

and now it works
"MasterGaurav" <ga**********@gmail.com> wrote in message
news:11********************@o13g2000cwo.googlegrou ps.com...
So, you get SearchList.SelectedIndex = 0 always?

What all other event-handlers do you have for the page? The situtation
is highly unlikely.

What version of ASP.Net (with SP) are you using? If you've applied SP
1, try reinstalling the javascript files. You can do this by:

%WINDIR%\Microsoft.Net\Framework\v1.1.4322\aspnet_ regiis -c
--
Cheers,
Gaurav Vaish
http://www.mastergaurav.org
http://mastergaurav.blogspot.com
----------------------

Nov 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: TJS | last post by:
can someone tell me why the selected item won't reflect user change in this little droplist example <%@ Page Language="VB" %> <script runat="server"> Sub Page_Load(ByVal sender As Object,...
2
by: TJS | last post by:
need help with trying to set selected value on a droplist. -- tried vCaptainID as integer and string , no luck -- tried it in pre render and also after droplist is created , no luck =========...
0
by: yuchang | last post by:
Hi, I try to use a droplist control to show a list value from Database table "A", and the droplist control is an item of a formview control, its data from Database table "B". My problem is how...
3
by: Alec MacLean | last post by:
Hi, I have a couple of win forms where I am editing values that are stored in a SQL database. I'm using the listbox control to hold the data object each form interacts with. Each object is...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.