在我的网格视图中,我希望当用户单击激活时,它会导航到 activate.aspx 页面。我想从上一页检索三个值到 activate.aspx 页面。我的代码是:
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);
}
标记:
<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" PostBackUrl='<%# "activate.aspx?RowIndex=" + Container.DataItemIndex %>' ></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>
但我无法检索上一页的值。
请帮助我。