从查询字符串填充Dropdownlist [英] Populating Dropdownlist from querystring

查看:116
本文介绍了从查询字符串填充Dropdownlist的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨...
我正在使用ASP.NET和c#开发Web应用程序.
我正在通过querystring将值从Page1.aspx传递给Page2.aspx.
我能够在文本框"中检索值,但我想在Dropdownlist中检索值.
例如,如果我在查询字符串中传递状态...则我在第2页的下拉列表应显示该状态.
请提及为此的任何代码...

Hi...
I am developing a web application using ASP.NET and c#.
I am passing values from Page1.aspx to Page2.aspx through querystring.
I am able to retrieve the values in Textbox,but I want to retrieve value in Dropdownlist.
Like,if i am passing Status in Querystring...then my Dropdownlist on page2 should show that Status.
Please mention any codes for this...

推荐答案

if(Request.QueryString["x"] != null)
dropDownList1.SelectedValue = Request.QueryString["x"].toString();



谢谢
Hiren Solanki



Thanks
Hiren Solanki


如果您读取查询字符串,则可以对从那里提取的数据进行任何操作.
If you read the query string, you can do whatever you like with the data you pull from there.


protected void Page_Load(object sender, EventArgs e)
{
dropDownList1.SelectedValue = Request.QueryString[querystring];
}



前提是将DropDownList的值"字段属性设置为您通过查询字符串传递的状态的值.



This is provided that the Value field property of the DropDownList is set to values of the status(s) you are passing thru the querystring.


这篇关于从查询字符串填充Dropdownlist的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆