GridView.Cells

Discussion in 'ASP .Net' started by Dot Net Daddy, Aug 4, 2006.

  1. Hello,

    I set one of the columns in the GridView to visible=false. But I want
    show the value in that column for the selected row, in a Label.

    I tried this one, but it didnt work:

    Protected Sub GridView1_SelectedIndexChanged(ByVal sender As
    Object, ByVal e As System.EventArgs) Handles
    GridView1.SelectedIndexChanged
    Label3.Text = GridView1.SelectedRow.Cells(3).Text
    End Sub

    Nothing shows even though the column has data. Then I tried the
    following one:

    Protected Sub GridView1_SelectedIndexChanged(ByVal sender As
    Object, ByVal e As System.EventArgs) Handles
    GridView1.SelectedIndexChanged
    GridView1.Columns(3).Visible = True
    Label3.Text = GridView1.SelectedRow.Cells(3).Text
    GridView1.Columns(3).Visible = False
    End Sub


    But it didn't work either. I think it is because the Page_Load sub
    function is run last.

    Can you please give any idea how to solve this problem.

    Thank you
     
    Dot Net Daddy, Aug 4, 2006
    #1
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    2
    Views:
    4,875
  2. Edwin Knoppert

    Gridview's findcontrol ignores cells()

    Edwin Knoppert, Nov 25, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    1,697
    Edwin Knoppert
    Nov 25, 2005
  3. Krish

    GridView Empty Cells

    Krish, Jan 11, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    2,953
    Krish
    Jan 11, 2006
  4. Replies:
    0
    Views:
    736
  5. =?Utf-8?B?TWF0dCBDb2xlZ3JvdmU=?=

    Mouseover/Mouseout for Gridview cells

    =?Utf-8?B?TWF0dCBDb2xlZ3JvdmU=?=, Mar 11, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    11,338
    =?Utf-8?B?TWF0dCBDb2xlZ3JvdmU=?=
    Mar 12, 2006
  6. =?Utf-8?B?bWdvbnphbGVzMw==?=

    GridView Hierarchical View - Gridview in Gridview

    =?Utf-8?B?bWdvbnphbGVzMw==?=, May 9, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    18,283
    =?Utf-8?B?UGhpbGxpcCBXaWxsaWFtcw==?=
    May 9, 2006
  7. K B
    Replies:
    1
    Views:
    9,184
    brianguy16
    Feb 21, 2008
  8. Joel Finkel

    Cells[].Text or Cells[].Controls[0]

    Joel Finkel, Sep 1, 2003, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    536
    Joel Finkel
    Sep 1, 2003
Loading...