如何将查询字符串从一个内容页面传递到另一个内容页面 [英] how to pass query string from one content page to another content page
本文介绍了如何将查询字符串从一个内容页面传递到另一个内容页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有两个页面一个default.aspx
公共部分类_Default:System.Web.UI.Page
{
protected void Page_Load(对象发送者,EventArgs e)
{
djfdl();
}
private void djfdl()
{
SqlDataAdapter adp = new SqlDataAdapter(select * from thousand,ConfigurationManager.ConnectionStrings [cn]。ConnectionString);
DataSet ds = new DataSet();
adp.Fill(ds);
DataList1.DataSource = ds;
DataList1.DataBind();
}
protected void DataList1_ItemCommand(object source,DataListCommandEventArgs e)
{
Response.Redirect(MasterPage.master-Default.aspx?pid =+ e.CommandArgument.ToString ());
}
}
第二页是DEFAULT2.ASPX
使用System;
使用System.Collections.Generic;
使用System.Linq;
使用System.Web;
使用System.Web.UI;
使用System.Web.UI.WebControls;
使用System.Data;
使用System.Data.SqlClient;
使用System.Configuration;
public partial class Default2:System.Web.UI.Page
{
protected void Page_Load(object sender,EventArgs e)
{
datab( );
}
private void datab()
{
string qry =select * from thousand where pid =+ Request.QueryString [pid]。ToString();
SqlDataAdapter adp = new SqlDataAdapter(qry,ConfigurationManager.ConnectionStrings [cn]。ConnectionString);
DataSet ds = new DataSet();
adp.Fill(ds);
DetailsView1.DataSource = ds;
DetailsView1.DataBind();
}
}
解决方案
你可以使用这段代码..
Eg :
IMGoBJ.Id = Convert.ToInt32(e.CommandArgument);
Response.Redirect(〜/ Pages / rajeeshmenoth.aspx?Qry =+ IMGoBJ.Id);
//第二页..页面加载
objNews.Id = Convert.ToInt32(Request.QueryString [Qry]);
i have two page one default.aspx
public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { djfdl(); } private void djfdl() { SqlDataAdapter adp = new SqlDataAdapter("select * from thousand", ConfigurationManager.ConnectionStrings["cn"].ConnectionString); DataSet ds = new DataSet(); adp.Fill(ds); DataList1.DataSource = ds; DataList1.DataBind(); } protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e) { Response.Redirect("MasterPage.master-Default.aspx?pid="+e.CommandArgument.ToString()); } }
SECOND PAGE IS DEFAULT2.ASPX
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data; using System.Data.SqlClient; using System.Configuration; public partial class Default2 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { datab(); } private void datab() { string qry = "select * from thousand where pid=" + Request.QueryString["pid"].ToString(); SqlDataAdapter adp = new SqlDataAdapter(qry, ConfigurationManager.ConnectionStrings["cn"].ConnectionString); DataSet ds = new DataSet(); adp.Fill(ds); DetailsView1.DataSource = ds; DetailsView1.DataBind(); } }
解决方案
u can use this code..
Eg:
IMGoBJ.Id = Convert.ToInt32(e.CommandArgument); Response.Redirect("~/Pages/rajeeshmenoth.aspx?Qry=" + IMGoBJ.Id); // second page..page load objNews.Id = Convert.ToInt32(Request.QueryString["Qry"]);
这篇关于如何将查询字符串从一个内容页面传递到另一个内容页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文