如何在页面加载时强制下拉列表选择? [英] How do I force drop down list selections on page load?
问题描述
我有一个Default.aspx,它可以重定向到Page1.aspx.我的ddl是从数据库加载并订购的.如何根据用户在默认"页面上选择的内容使ddl选择显示在页面加载中?
I have a Default.aspx that redirects to a Page1.aspx. My ddl is loaded and ordered from a database. How do I make the ddl selection show up on the page load depending on what the user selects on the Default page?
推荐答案
您需要将某种数据从Default.aspx传递到Page1.aspx.我建议使用查询字符串.因此,例如在Default.aspx上,您将重定向到:
You will need to pass some kind of data from Default.aspx to Page1.aspx. I would suggest using a query string. So for example on Default.aspx you would redirect to:
Response.Redirect(〜/Page1.aspx?selectValue = 5");
然后在Page_Load的Page1.aspx上执行类似的操作
And then on Page1.aspx in Page_Load you would do something like
myDropDownList.SelectedValue = Request.QueryString("selectValue");
显然,您需要对Page1.aspx进行更多检查,以确保存在Request.QueryString("selectValue")等,但是您明白了.
Obviously you'll need to do some more checking on Page1.aspx to make sure Request.QueryString("selectValue") exists, etc. but you get the idea.
编辑-这是C#,因此添加了分号;)
edit-this is C#, so added the semicolon ;)
这篇关于如何在页面加载时强制下拉列表选择?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!