读书人

C#页面跳转判断,该如何解决

发布时间: 2013-03-27 11:22:42 作者: rapoo

C#页面跳转判断
我有1个新建按钮
/新建按钮
protected void btnNew_Click(object sender, EventArgs e)
{

Response.Redirect("ProductDetails.aspx?product=1"); }
和一个protected void GridShow_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
//当鼠标停留时更改背景色
e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#9CCBF7';this.style.cursor='hand'");
//当鼠标移开时还原背景色
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");
//string strId = GridView1.DataKeys[e.Row.RowIndex].Value.ToString();
e.Row.Attributes.Add("ondblclick", "window.open('ProductDetails.aspx?Product=2 CODE=" + GridShow.DataKeys[e.Row.RowIndex].Value + "')");
}
}
2个都跳转到 'ProductDetails.aspx
那么我在'ProductDetails.aspx表的
protected void Page_Load(object sender, EventArgs e)
{
}里面怎么判断是那个跳过来的?

[解决办法]
判断product参数啊

if(Request.QueryString["product"]=="1")
{
//btnNew按钮点击过来的
}
else
{
//绑定链接点击过来的
}

另外你上面的参数product大小写最好一致,CODE参数前要加&,即...product=2&CODE=...
[解决办法]
你在传一个ID嘛,去判断,如果没这个ID就直接跳走,如果有就用这个ID去查询详细信息(参数之间用 & 这个符号链接 ProductDetails.aspx?Product=2&CODE=" + GridShow.DataKeys[e.Row.RowIndex].Value + "')
protected void GridShow_RowDataBound(object sender, GridViewRowEventArgs e)
{
e.Row.Attributes.Add("ondblclick", "window.open('ProductDetails.aspx?Product=2&CODE=" + GridShow.DataKeys[e.Row.RowIndex].Value + "')");

你可以在ProductDetails.aspx页面去获取这个Product和CODE
如果这里的CODE是ID那你就根据这个ID去查询就OK了


[解决办法]

引用:
我是双击GridView详细跳转到这个页面的,我想让双击的详细信息显示到这个页面上
用一个方法 将这个详细信息都写到这个方法里面,然后在 else{
里面去 调用哪个方法
}
我双击跳转过来后 页面上会显示我的那些信息吗?
会呀,你加上相应的代码处理就可以了。
[解决办法]
你加上类型,不就可以了吗?
------解决方案--------------------


应该给按钮一个值,再跳到下一个页面里在下一下页面里的构造函数里来判断就行了,打开哪个页面。

读书人网 >C#

热点推荐