470,590 Members | 2,525 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,590 developers. It's quick & easy.

Show and Hide embedded GridView

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
Sep 28 '07 #1
1 2452
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" <dlch...@lifetimeinc.comwrote:
...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 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Sandra | last post: by
12 posts views Thread by Jerad Rose | last post: by
reply views Thread by Reinhard | last post: by
reply views Thread by gnewsgroup | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.