Response.Redirect页面传值问题
言月秋 2015-07-08 02:11:02 <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 = "";
}
估计报错原因为未接受到上个页面传过来的值,所以判断时报错,大家看下我传值哪里写错了。