私のグリッド ビューでは、ユーザーがアクティブ化をクリックすると、activate.aspx ページに移動します。そして、前のページから activate.aspx ページに 3 つの値を取得したいと考えています。私のコードは次のとおりです。
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>
しかし、前のページの値を取得できません。
助けてください。