protected void Button1_Click(object sender, EventArgs e)
{
ViewState.Clear();
string key = " ShowType=" + Request.QueryString["type"] + " and"; 解释一下这句
if (TextBox1.Text.Length > 0)
key += string.Format(" Address like '%{0}%' and", TextBox1.Text); 我理解的这句是将TextBox1.Text内容发给{0} 然后进行地址查询 然后赋值给key
if(TextBox2.Text.Length>0&&TextBox3.Text.Length==0)TextBox1.Text
key += string.Format(" price > {0} and", TextBox2.Text);
if (TextBox2.Text.Length == 0 && TextBox3.Text.Length > 0)
key += string.Format(" price < {0} and", TextBox3.Text);
if (TextBox2.Text.Length > 0 && TextBox3.Text.Length > 0)
key += string.Format(" (price between {0} and {1}) and", TextBox2.Text,TextBox3.Text);
if(DropDownList1.SelectedIndex>0)
key += string.Format(" HouseType_ID={0} and", DropDownList1.SelectedValue);
if(DropDownList2.SelectedIndex>0)
key += string.Format(" Form='{0}' and", DropDownList2.SelectedItem.Text);
if (DropDownList3.SelectedIndex > 0)
key += string.Format(" Qu_ID={0} and", DropDownList3.SelectedValue);
if (key.Length > 0)
key = key.Substring(0, key.Length - 3);
ViewState["key"] = key;
Bind();
}<span style="font-weight:bold; color:White"><a href="house.aspx?type=1" style="font-size:20px; color:White">出租房源</a> | </span>
<span style="font-weight:bold; color:White"><a href="house.aspx?type=2" style="font-size:20px; color:White">出售房源</a> | </span> 一个页面被两个链接使用 才出现了type 顺便解释下ViewState
希望大神们能给小弟详细解释一下
{
ViewState.Clear();
string key = " ShowType=" + Request.QueryString["type"] + " and"; 解释一下这句
if (TextBox1.Text.Length > 0)
key += string.Format(" Address like '%{0}%' and", TextBox1.Text); 我理解的这句是将TextBox1.Text内容发给{0} 然后进行地址查询 然后赋值给key
if(TextBox2.Text.Length>0&&TextBox3.Text.Length==0)TextBox1.Text
key += string.Format(" price > {0} and", TextBox2.Text);
if (TextBox2.Text.Length == 0 && TextBox3.Text.Length > 0)
key += string.Format(" price < {0} and", TextBox3.Text);
if (TextBox2.Text.Length > 0 && TextBox3.Text.Length > 0)
key += string.Format(" (price between {0} and {1}) and", TextBox2.Text,TextBox3.Text);
if(DropDownList1.SelectedIndex>0)
key += string.Format(" HouseType_ID={0} and", DropDownList1.SelectedValue);
if(DropDownList2.SelectedIndex>0)
key += string.Format(" Form='{0}' and", DropDownList2.SelectedItem.Text);
if (DropDownList3.SelectedIndex > 0)
key += string.Format(" Qu_ID={0} and", DropDownList3.SelectedValue);
if (key.Length > 0)
key = key.Substring(0, key.Length - 3);
ViewState["key"] = key;
Bind();
}<span style="font-weight:bold; color:White"><a href="house.aspx?type=1" style="font-size:20px; color:White">出租房源</a> | </span>
<span style="font-weight:bold; color:White"><a href="house.aspx?type=2" style="font-size:20px; color:White">出售房源</a> | </span> 一个页面被两个链接使用 才出现了type 顺便解释下ViewState
希望大神们能给小弟详细解释一下
解决方案 »
- c# 如何操作Excel生成柱形图
- 在vs2003中怎么实现页面的局部刷新
- net framework 总是出这个错误??晕!没有人知道这个问题吗?
- 求助,如何,winform c# 读取EXCEL模板 然后再把数据写入EXCEL
- C#求助!!如何动态创建新的form窗体 再在这个新的FORM窗体创建新的控件.
- 如何匹配配对的双引号
- 开源:.NET绘制打印网格线、单元格文本,各种网格如DataGrid打印、DataTable、HtmlTable等二维形式全搞定
- 创建控件时出错-ScriptManager
- DriveInfo 类的属性
- 需求一个vs.net2003下的查询分页程序
- wpf问题??
- c#ToString问题
拼接字符串也要解释
Like this
string type = Request.QueryString["type"];ViewState 在当前页面保存数据
ViewState["key"] = " ShowType=" + Request.QueryString["type"]
的意思是将地址栏里的type的值存储在ViewState里