开发者

How do I send a value from a gridview control button field to another page?

protected void GridView3_RowCommand(object sender, GridViewCommandEventArgs e)
{
    if (e.CommandName == "Drill")
    {
        int index = Convert.ToInt32(e.CommandArgument);

        GridVi开发者_开发问答ewRow selectedRow = GridView3.Rows[index];
        TableCell sitenamecell = selectedRow.Cells[1];
        string Site = sitenamecell.Text;
        Session["Location"] = Site;
        lblSession.Text = Session["Location"].ToString();
        Response.Redirect("DisplayForm.aspx");


I am assuming your other page is the page you are redirecting to?

If so just add whatever you want to the query string:

Response.Redirect("DisplayForm.aspx?yourParamNameHere=" + yourParamNameValue); 

You can use the session but then you have to worry about the back button, forward buttons and multiple tabs (instances) messing up what is stored in the session. The safest method is to just make it part of the query string that your receiving page looks for.


You could do it as a GET variable:

GridViewRow selectedRow = GridView3.Rows[index];
TableCell sitenamecell = selectedRow.Cells[1];
string Site = sitenamecell.Text;
Session["Location"] = Site;
lblSession.Text = Session["Location"].ToString();
Response.Redirect("DisplayForm.aspx?site=" + Site);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜