Results 1 to 4 of 4
  1. #1
    Lounger
    Join Date
    Jan 2002
    Location
    Rochester, Kent, United Kingdom
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Datagrid Select (c# asp.net 2005)

    Hi guys
    I've got a data grid with an ID field showing all info for everyone, I want to click the 'Select' button and redirect to another form that only shows details for the selected person. Heres what I've done.... but it dont work!

    On Datagrid form:-
    protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
    {
    string val = GridView1.SelectedIndex.ToString();
    string URL = "?ID=" + val;
    Response.Write("*" + URL + "*");

    Response.Redirect("~/individual.aspx" + URL);
    DataBind();
    }

    On Redirect form:-
    protected void Page_Load()
    {
    tb.Text = Request.QueryString["URL"].ToString();
    FormView1.ID = Request.QueryString["URL"];

    }

    Any help much appreaciated
    Si

  2. #2
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    1,862
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Datagrid Select (c# asp.net 2005)

    I'm not sure what else might be failing, but one thing that seems like a good place to start is this:

    On the redirect form, you'll want to read the querystring value of ID rather than URL.

    Post back if that doesn't do the trick.

  3. #3
    Lounger
    Join Date
    Jan 2002
    Location
    Rochester, Kent, United Kingdom
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Datagrid Select (c# asp.net 2005)

    Mark

    URL is the query string, bad nameing on my part

  4. #4
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    1,862
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Datagrid Select (c# asp.net 2005)

    I understand - however, if your url looks like this: http://...../page.aspx?id=<someValue>

    then you'll want to use Request.Querystring["id"] to retrieve the querystring parameter called "id".

    Based on the code you posted, you'll want to make sure that you request the matching querystring parameter name. The change I suggested will correct the mismatch in that particular example.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •