Show and Hide embedded GridView

D

David C

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
 
N

nothingsoriginalontheinternet

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top