reading hidden data from a gridview control

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?UGF1bA==?=

    reading hidden data from a gridview control

    Hi I am trying to read hidden data from a gridview control. This works if
    the data is visible but if the column is not visible it does not return
    anything, thanks.
    Int32 itemp = Convert.ToInt32 (e.Row.Cells[6].Text);
    --
    Paul G
    Software engineer.
  • Eliyahu Goldin

    #2
    Re: reading hidden data from a gridview control

    If you hide the column with Visible=true, it won't be rendered and won't be
    in the Cells collection. Add the column to the DataKeyNames, then you can
    get it the DataKeys array.

    --
    Eliyahu Goldin,
    Software Developer
    Microsoft MVP [ASP.NET]




    "Paul" <Paul@discussio ns.microsoft.co mwrote in message
    news:5A344629-628D-455F-9A5A-AA8AD1C490F5@mi crosoft.com...
    Hi I am trying to read hidden data from a gridview control. This works if
    the data is visible but if the column is not visible it does not return
    anything, thanks.
    Int32 itemp = Convert.ToInt32 (e.Row.Cells[6].Text);
    --
    Paul G
    Software engineer.

    Comment

    • Mark Rae [MVP]

      #3
      Re: reading hidden data from a gridview control

      "Paul" <Paul@discussio ns.microsoft.co mwrote in message
      news:5A344629-628D-455F-9A5A-AA8AD1C490F5@mi crosoft.com...
      Hi I am trying to read hidden data from a gridview control. This works if
      the data is visible but if the column is not visible it does not return
      anything, thanks.
      Int32 itemp = Convert.ToInt32 (e.Row.Cells[6].Text);
      When you set a webcontrol's Visible property to false, it does not even get
      rendered to the client browser.

      Therefore, you will need to use CSS to hide it client-side.

      Lots of examples of this are available:



      --
      Mark Rae
      ASP.NET MVP


      Comment

      • =?Utf-8?B?UGF1bA==?=

        #4
        Re: reading hidden data from a gridview control

        Hi, thanks for the responses. I ended up converting the bound column to a
        template column with a lable (lblDiscID) then used Int32 itemp
        =Convert.ToInt3 2 ( (e.Row.Cells[6].FindControl("l blDiscID") as Label).Text);
        which seemed to work. Guess there are a few ways to do it.
        --
        Paul G
        Software engineer.


        "Mark Rae [MVP]" wrote:
        "Paul" <Paul@discussio ns.microsoft.co mwrote in message
        news:5A344629-628D-455F-9A5A-AA8AD1C490F5@mi crosoft.com...
        >
        Hi I am trying to read hidden data from a gridview control. This works if
        the data is visible but if the column is not visible it does not return
        anything, thanks.
        Int32 itemp = Convert.ToInt32 (e.Row.Cells[6].Text);
        >
        When you set a webcontrol's Visible property to false, it does not even get
        rendered to the client browser.
        >
        Therefore, you will need to use CSS to hide it client-side.
        >
        Lots of examples of this are available:

        >
        >
        --
        Mark Rae
        ASP.NET MVP

        >
        >

        Comment

        Working...