Response.Redirect页面传值问题
<asp:GridView ID="GridView1" runat="server" Visible="False" OnRowEditing="GridView_RowEditing" onselectedindexchanged="GridView1_SelectedIndexChanged">
<Columns>
<asp:ButtonField CommandName="Edit" Text="详细" />
</Columns>
</asp:GridView>
gridview中绑定了 protected void GridView_RowEditing(object sender, GridViewEditEventArgs e)
{
this.GridView1.EditIndex = e.NewEditIndex;
int selectIndex = this.GridView1.EditIndex;
string louhao = this.GridView1.Rows[selectIndex].Cells[1].Text.ToString();
string qinshihao = this.GridView1.Rows[selectIndex].Cells[2].Text.ToString();
base.Response.Redirect("detailed.aspx?louhao =" + louhao + "&qinshihao=" + qinshihao + " " );
}
detailed.aspx中
string louhao = Server.UrlDecode(Request["louhao"]);
string qinshihao = Server.UrlDecode(Request["qinshihao"]);
Response.Write("<script>alert('" + louhao + "')</script>");
Response.Write("<script>alert('" + qinshihao + "')</script>");
if (!louhao.Trim().Equals("")) 这里报错未将对象引用设置到对象的实例。
{
louhao = " and louhao='" + louhao + "'";
}
else
{
louhao = "";
}
估计报错原因为未接受到上个页面传过来的值,所以判断时报错,大家看下我传值哪里写错了。
<Columns>
<asp:ButtonField CommandName="Edit" Text="详细" />
</Columns>
</asp:GridView>
gridview中绑定了 protected void GridView_RowEditing(object sender, GridViewEditEventArgs e)
{
this.GridView1.EditIndex = e.NewEditIndex;
int selectIndex = this.GridView1.EditIndex;
string louhao = this.GridView1.Rows[selectIndex].Cells[1].Text.ToString();
string qinshihao = this.GridView1.Rows[selectIndex].Cells[2].Text.ToString();
base.Response.Redirect("detailed.aspx?louhao =" + louhao + "&qinshihao=" + qinshihao + " " );
}
detailed.aspx中
string louhao = Server.UrlDecode(Request["louhao"]);
string qinshihao = Server.UrlDecode(Request["qinshihao"]);
Response.Write("<script>alert('" + louhao + "')</script>");
Response.Write("<script>alert('" + qinshihao + "')</script>");
if (!louhao.Trim().Equals("")) 这里报错未将对象引用设置到对象的实例。
{
louhao = " and louhao='" + louhao + "'";
}
else
{
louhao = "";
}
估计报错原因为未接受到上个页面传过来的值,所以判断时报错,大家看下我传值哪里写错了。
...全文
相关推荐
aspx页面间传值介绍
aspx页面间传值介绍 aspx页面间传值介绍
ASP.NET的几种传值方式
ASP.NET的几种传值方式,学习ASP.NET必须要掌握的几种方式
asp.net实现页面传值的方法集合
asp.net实现页面传值的方法集合,在这里统一做了汇总!!对您理清.net传值的方式有会有很大的帮助!!
ASPNET跨页面传值技巧
ASPNET跨页面传值技巧 京华志&精华志出品 分享资源 C# ASP.NET SQL DBA 源码
webform页面间传值的三种方法
在webform中实现三种从一个页面向另一个页面的传值方法。response.Redirect、session、server.Transfer.


