在下拉列表中选择了错误的选项 [英] wrong option selected in dropdownlist
问题描述
我有一个带有事件处理程序的绑定下拉列表
OnSelectedIndexChanged。
如果我选择一个值我''被重定向到另一个页面。我使用
返回浏览器的后退按钮,选项仍然处于选中状态。到目前为止
好。但非常奇怪的是,如果我查看源代码:
< option selected =" selected" value =" 13808"> DataPage6< / option>
< option value =" 13805"> DataPage5< / option>
< option value = " 13489"> DataPage4< / option>
然而,我已经在列表中选择了第二项(DataPage5)。
所以那里发生了什么????
感谢您的帮助。
Sam
Hi,
I have a bound dropdownlist with an event handler
OnSelectedIndexChanged.
If I select a value I''m redirected to another page. I come back using
the browser''s back button, and the option is still selected. So far so
good. But the very weird thing is that if I look at the source code :
<option selected="selected" value="13808">DataPage6</option>
<option value="13805">DataPage5</option>
<option value="13489">DataPage4</option>
and yet, I''ve got the second item (DataPage5) selected in the list.
So what''s going on there ????
Thanks for helping.
Sam
推荐答案
你能说清楚......实际问题是什么......
你想要什么?
发生了什么事?
谢谢..
" sam" < SA ************* @ googlemail.com>在消息中写道
新闻:11 ********************** @ i39g2000cwa.googlegr oups.com ...
Hi,
Would you make it bit clear .. what is actual problem....
What you want?
What is happening?
Thanks..
"sam" <sa*************@googlemail.com> wrote in message
news:11**********************@i39g2000cwa.googlegr oups.com...
我有一个带有事件处理程序的绑定下拉列表
OnSelectedIndexChanged。
如果我选择一个值,我会被重定向到另一个页面。我回来后使用浏览器的后退按钮,选项仍然被选中。到目前为止很好。但非常奇怪的是,如果我查看源代码:
< option selected =" selected" value =" 13808"> DataPage6< / option>
< option value =" 13805"> DataPage5< / option>
< option value =" 13489"> DataPage4< / option>
然而,我已经在列表中选择了第二项(DataPage5)。
那么那里发生了什么????
感谢您的帮助。
Sam
Hi,
I have a bound dropdownlist with an event handler
OnSelectedIndexChanged.
If I select a value I''m redirected to another page. I come back using
the browser''s back button, and the option is still selected. So far so
good. But the very weird thing is that if I look at the source code :
<option selected="selected" value="13808">DataPage6</option>
<option value="13805">DataPage5</option>
<option value="13489">DataPage4</option>
and yet, I''ve got the second item (DataPage5) selected in the list.
So what''s going on there ????
Thanks for helping.
Sam
好的,请注意:
In加载事件:
如果不是IsPostBack然后
''从数据库获取数据并绑定下拉列表
结束如果
在selectedindexchanged事件处理程序中:
Public Sub OnSelectedIndexChanged(ByVal sender As Object,ByVal e As
EventArgs)
Dim q作为新查询(CType(发件人,
DropDownList).SelectedItem.Text,CInt(CType(发件人,
DropDownList).SelectedItem .Value))
Session(" CurrentQuery")= q
Response.Redirect(" Flow.aspx&qu ot;)
结束子
然后当我从Flow.aspx浏览回到我的页面时,选择项目在
下拉列表中仍然是我选择的那个,这是预期的,但是如果我做查看源代码的话,那么html代码就是:
< option选定= QUOT;选择" value =" 13808"> DataPage6< / option>
< option value =" 13805"> DataPage5< / option>
< option value = " 13489"> DataPage4< / option>
即使selecteditem是DataPage5或DataPage4。对我来说,这并没有给我带来感觉。
你能帮忙吗?
Ok, watch that :
In the load event:
If Not IsPostBack Then
''get data from database and bind dropdownlist
End If
in the selectedindexchanged event handler:
Public Sub OnSelectedIndexChanged(ByVal sender As Object, ByVal e As
EventArgs)
Dim q As New Query(CType(sender,
DropDownList).SelectedItem.Text, CInt(CType(sender,
DropDownList).SelectedItem.Value))
Session("CurrentQuery") = q
Response.Redirect("Flow.aspx")
End Sub
Then when I browse back from Flow.aspx to my page, the selecteditem in
dropdownlist is still the one I had selected, which is expected, BUT
the html code if I do ''View Source'' is:
<option selected="selected" value="13808">DataPage6</option>
<option value="13805">DataPage5</option>
<option value="13489">DataPage4</option>
even if the selecteditem is DataPage5 or DataPage4. It doesn''t make
sense to me.
Can you help ?
通常情况下,后退按钮不会导致页面重新加载。它从
获取本地缓存。你必须特别注意让页面重新加载。
Eliyahu
" sam" < SA ************* @ googlemail.com>在消息中写道
新闻:11 ********************** @ i39g2000cwa.googlegr oups.com ...
Normally, the Back button doesn''t cause the page to re-load. It gets it from
a local cache. You have to take special care to get the page to reload.
Eliyahu
"sam" <sa*************@googlemail.com> wrote in message
news:11**********************@i39g2000cwa.googlegr oups.com...
我有一个带有事件处理程序的绑定下拉列表
OnSelectedIndexChanged。
如果我选择一个值,我会被重定向到另一个页面。我回来后使用浏览器的后退按钮,选项仍然被选中。到目前为止很好。但非常奇怪的是,如果我查看源代码:
< option selected =" selected" value =" 13808"> DataPage6< / option>
< option value =" 13805"> DataPage5< / option>
< option value =" 13489"> DataPage4< / option>
然而,我已经在列表中选择了第二项(DataPage5)。
那么那里发生了什么????
感谢您的帮助。
Sam
Hi,
I have a bound dropdownlist with an event handler
OnSelectedIndexChanged.
If I select a value I''m redirected to another page. I come back using
the browser''s back button, and the option is still selected. So far so
good. But the very weird thing is that if I look at the source code :
<option selected="selected" value="13808">DataPage6</option>
<option value="13805">DataPage5</option>
<option value="13489">DataPage4</option>
and yet, I''ve got the second item (DataPage5) selected in the list.
So what''s going on there ????
Thanks for helping.
Sam
这篇关于在下拉列表中选择了错误的选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!