Show and Hide embedded GridView

Discussion in 'ASP .Net' started by David C, Sep 28, 2007.

  1. David C

    David C Guest

    I have a GridView of contacts that contains an embedded gridview of multiple
    phones for that particular contact. I have a LinkButton on the contacts
    GridView that refers to the Select command and when I click it the embedded
    GridView of phones becomes visible. Now I would like to have it toggle so
    that if the embedded GridView is visible, it will become Visible = False.
    Below is the code I have but it creates an error "Object reference not set
    to an instance of an object" c on the first IF statement. Can someone
    advise? Code is below:

    Protected Sub LBtnMorePhones_Click(ByVal sender As Object, ByVal e As
    CommandEventArgs)
    txtcnid.Text = e.CommandArgument
    Dim row As GridViewRow = gvContacts.SelectedRow
    If Not row.FindControl("gvMorePhones") Is Nothing Then
    Dim varControl
    varControl = row.FindControl("gvMorePhones")
    If Not varControl Is Nothing Then
    varControl.Visible = Not varControl.Visible
    End If
    End If
    End Sub
    David C, Sep 28, 2007
    #1
    1. Advertising

  2. David C

    Guest

    I believe gvContacts.SelectedRow is not returning anything.

    Maybe a possible workaround is to handle the OnLoad event with the
    OnLoad attribute of the phone numbers gridview, and work your way out
    instead of in to find if the row that contains it is selected.

    -Mike Placentra II


    On Sep 28, 1:45 pm, "David C" <> wrote:
    > ...error "Object reference not set
    > to an instance of an object" c on the first IF statement. Can someone
    > advise? Code is below:
    >
    > ...
    > Dim row As GridViewRow = gvContacts.SelectedRow
    > ...
    , Sep 29, 2007
    #2
    1. Advertising

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. Sandra
    Replies:
    2
    Views:
    870
    Gernot Frisch
    Nov 8, 2004
  2. Reinhard
    Replies:
    0
    Views:
    742
    Reinhard
    Jun 3, 2007
  3. gnewsgroup

    Dynamically show/hide gridview footer?

    gnewsgroup, Oct 23, 2007, in forum: ASP .Net
    Replies:
    0
    Views:
    4,873
    gnewsgroup
    Oct 23, 2007
  4. Replies:
    0
    Views:
    87
  5. ll
    Replies:
    2
    Views:
    632
    Thomas 'PointedEars' Lahn
    May 1, 2008
Loading...

Share This Page