Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. GridView to DetailsView (on a different page), passing of variable

GridView to DetailsView (on a different page), passing of variable

Scheduled Pinned Locked Moved ASP.NET
questionhelp
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Desmond Lim
    wrote on last edited by
    #1

    Hi, I'm trying to get the key of the GridView into the DetailsView and using Session doesn't seem to work. The GridView (Parent page) has summaries of the data. I'm using a to get the ID and redirect to the DetailsView page (Child page). 2 different pages. What I'm currently doing is this protected void GridView1_SelectedIndexChanged(object sender, EventArgs e) { Session["ID"] = GridView1.Rows[0].ToString(); Response.Redirect("DetailsPage.aspx"); } And the DetailsPage has this for getting the parameter I know the problem is that the data types are incompatible but how can I cast the data? Or is the problem more than that. If this is the wrong way, how can I pass the ID from the parent to the child (different pages)? And I don't want to put the data in the URL. Thanks. Desmond

    V 1 Reply Last reply
    0
    • D Desmond Lim

      Hi, I'm trying to get the key of the GridView into the DetailsView and using Session doesn't seem to work. The GridView (Parent page) has summaries of the data. I'm using a to get the ID and redirect to the DetailsView page (Child page). 2 different pages. What I'm currently doing is this protected void GridView1_SelectedIndexChanged(object sender, EventArgs e) { Session["ID"] = GridView1.Rows[0].ToString(); Response.Redirect("DetailsPage.aspx"); } And the DetailsPage has this for getting the parameter I know the problem is that the data types are incompatible but how can I cast the data? Or is the problem more than that. If this is the wrong way, how can I pass the ID from the parent to the child (different pages)? And I don't want to put the data in the URL. Thanks. Desmond

      V Offline
      V Offline
      Venkatesh Mookkan
      wrote on last edited by
      #2

      Desmond Lim wrote:

      Session["ID"] = GridView1.Rows[0].ToString();

      Its seems like you are not getting values from any of the cells in the GridView. Mostly your Session object would have the text of the data type of GridViewRow like "System.Web....GridViewRow". try like, Session["ID"] = GridView1.Rows[0].Cell[cellIndex].Text; or Session["ID"] = Convert.ToInt32(GridView1.Rows[0].Cell[cellIndex].Text); where cellIndex is the index of the gridview's column

      [Venkatesh Mookkan] My: Website | Yahoo Group | Blog Spot

      D 1 Reply Last reply
      0
      • V Venkatesh Mookkan

        Desmond Lim wrote:

        Session["ID"] = GridView1.Rows[0].ToString();

        Its seems like you are not getting values from any of the cells in the GridView. Mostly your Session object would have the text of the data type of GridViewRow like "System.Web....GridViewRow". try like, Session["ID"] = GridView1.Rows[0].Cell[cellIndex].Text; or Session["ID"] = Convert.ToInt32(GridView1.Rows[0].Cell[cellIndex].Text); where cellIndex is the index of the gridview's column

        [Venkatesh Mookkan] My: Website | Yahoo Group | Blog Spot

        D Offline
        D Offline
        Desmond Lim
        wrote on last edited by
        #3

        Thanks Venkatesh

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups