我的查询字符串有问题. [英] A problem with my querystring.
本文介绍了我的查询字符串有问题.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
< body > ;
< 表单 =" form1" runat >服务器" >
< div >
< asp:DropDownList ID =" runat 服务器" 宽度 165像素" < asp:ListItem > [选择组] < /asp:ListItem >
< asp:ListItem > A + < /asp:ListItem >
< asp:ListItem > B + < /asp:ListItem >
< asp:ListItem > AB + < /asp:ListItem >
< asp:ListItem > O + < /asp:ListItem >
< asp:ListItem > A -< /asp:ListItem >
< asp:ListItem > B -< /asp:ListItem >
< asp:ListItem > AB -< /asp:ListItem >
< asp:ListItem > O -< /asp:ListItem >
< /asp:DropDownList >
< asp:DropDownList ID =" runat 服务器" 宽度 167像素" < asp:ListItem > Jammu克什米尔< /asp:ListItem >
< /asp:DropDownList >
< asp:DropDownList ID =" runat 服务器" 宽度 167像素" < asp:ListItem > Jammu < /asp:ListItem >
< asp:ListItem > 斯利那加< /asp:ListItem >
< /asp:DropDownList >
< asp:Button ID =" runat 服务器" OnClick Button1_Click" 文本 搜索" Width =" / > br / >
< br >
< /div >
< /form >
< /body >
后面的代码是这样的
使用系统;
使用 System.Data;
使用 System.Configuration;
使用 System.Collections;
使用 System.Web;
使用 System.Web.Security;
使用 System.Web.UI;
使用使用System.Web.UI.WebControls;
使用 System.Web.UI.WebControls.WebParts;
使用 System.Web.UI.HtmlControls;
公共 部分 class 搜索:System.Web .UI.页面
{
受保护的 无效 Page_Load(对象发件人,EventArgs e)
{
}
受保护的 无效 Button1_Click(对象发件人,EventArgs e)
{
Response.Redirect(" + DropDownList2.SelectedItem.Text + " + DropDownList3.SelectedItem.Text + " & city =" + DropDownList1.SelectedItem.Text);
}
}
但是我在传递这些查询字符串的网格视图中没有得到结果
我认为这是因为当我们在查询字符串中传递A +,A-,AB +时会产生问题
请告诉我出路.
解决方案
对于您的要求,只需将"+"替换为任何其他字符即可.检查样品
Response.Redirect(" + DropDownList2 .SelectedItem.Text.Replace(' +',' /')+ " + DropDownList3.SelectedItem.Text + & city =" + DropDownList1. SelectedItem.Text); // 获取类似的值 字符串 str = Request.QueryString [" span>].ToString().Replace(' /', +');
^ ]
,也可以使用
100:rose:;)
hi guys,
<body>
<form id="form1" runat="server">
<div>
<asp:DropDownList ID="DropDownList2" runat="server" Width="165px">
<asp:ListItem>[Select Group]</asp:ListItem>
<asp:ListItem>A+ </asp:ListItem>
<asp:ListItem>B+ </asp:ListItem>
<asp:ListItem>AB+ </asp:ListItem>
<asp:ListItem>O+ </asp:ListItem>
<asp:ListItem>A-</asp:ListItem>
<asp:ListItem>B-</asp:ListItem>
<asp:ListItem>AB-</asp:ListItem>
<asp:ListItem>O-</asp:ListItem>
</asp:DropDownList>
<asp:DropDownList ID="DropDownList3" runat="server" Width="167px">
<asp:ListItem>Jammu Kashmir</asp:ListItem>
</asp:DropDownList>
<asp:DropDownList ID="DropDownList1" runat="server" Width="167px">
<asp:ListItem>Jammu</asp:ListItem>
<asp:ListItem>Srinagar</asp:ListItem>
</asp:DropDownList>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Search" Width="88px" /><br />
<br />
</div>
</form>
</body>
code behind is like this
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class search : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
Response.Redirect ("search_donor.aspx?bg=" + DropDownList2.SelectedItem.Text + "&st=" + DropDownList3.SelectedItem.Text + "&city=" + DropDownList1.SelectedItem.Text);
}
}
but I am not getting the results in the grid view where I pass these querystrings
i think this is because of A+,A-,AB+ when we pass it in query string it creates a problem
please tell me way out.
解决方案
For your requirement just replace the ''+'' with any other character. Check the sample
Response.Redirect("search_donor.aspx?bg=" + DropDownList2.SelectedItem.Text.Replace('+', '/') + "&st=" + DropDownList3.SelectedItem.Text + "&city=" + DropDownList1.SelectedItem.Text); //Retrieve the value like string str=Request.QueryString["bg"].ToString().Replace('/','+');
http://stackoverflow.com/questions/123994/querystring-malformed-after-urldecode[^]
or you can use<a href="http://msdn.microsoft.com/en-us/library/6196h3wt.aspx" target="_balnk">Server.UrlDecode(string s)<br /> </a>
100:rose: ;)
这篇关于我的查询字符串有问题.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文