在我的网格视图中,我希望当用户单击激活时,它会导航到 activate.aspx 页面。我想从上一页检索三个值到 activate.aspx 页面。我的代码是:
protected void Page_Load(object sender, EventArgs e)
{
if (this.Page.PreviousPage != null)
{
int rowIndex = int.Parse(Request.QueryString["RowIndex"]);
GridView GridView1 = (GridView)this.Page.PreviousPage.FindControl("GridView1");
GridViewRow row = GridView1.Rows[rowIndex];
Label1.Text = row.Cells[3].Text;
Label2.Text = row.Cells[2].Text;
Label3.Text = row.Cells[2].Text;
SqlDataAdapter da = new SqlDataAdapter("insert into login values('" + Label1.Text + "','" + Label2.Text + "','" + Label3.Text + "')",con);
DataSet ds = new DataSet();
da.Fill(ds);
}
}
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Redirect")
{
String email = "lblemail.Text";
String mob = "lblmobno.Text";
Server.Transfer("activate.aspx?RowIndex=" + email +mob, true);
}
}
Aspx 标记
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false"
onrowcommand="GridView1_RowCommand">
<Columns>
<asp:TemplateField HeaderStyle-Font-Bold="true" HeaderStyle-Font-Size="Larger" HeaderText="Activate/Delete"
ItemStyle-Width="150px">
<ItemTemplate>
<asp:LinkButton ID="linkbutton1" runat="server" Text="Activate" CommandName="Redirect"
CommandArgument='<%# DataBinder.Eval(Container, "RowIndex") %>'></asp:LinkButton>
<span onclick="return confirm('Are You sure want to Delete?')">
<asp:LinkButton ID="linkbutton2" runat="server" Text="Delete" CommandName="Delete"></asp:LinkButton>
</span>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
我收到以下行的输入字符串格式不正确的错误:
int rowIndex = int.Parse(Request.QueryString["RowIndex"]);
请帮助我。