capella2007
Programmer
Hi, First, so you know what environment I'm working in, I have VS 2005 Pro, and I'm using VB code-behind pages.
The subject essentially describes what I'm trying to do: I have a GridView and a FormView on a page and I want only the GridView to display on page load and the FormView to only show up when the user clicks a linkbutton, at which time the GridView "disappears".
I've tried messing with the visible properties of both the Grid- and FormViews, while at the same time changing the visible properties on the page load and button click events in the code-behind page:
[BEGIN VB CODE]
Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim formview1 As New FormView
Dim gridview1 As New GridView
gridview1.Visible = True
formview1.Visible = False
End Sub
Protected Sub LinkButton1_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim gridview1 As New GridView
Dim linkbutton1 As New LinkButton
Dim formview1 As New FormView
GridView1.Visible = False
linkbutton1.Visible = False
formview1.Visible = True
End Sub
[END VB CODE]
This code doesn't quite work. The only way I've been able to "hide" and "unhide" the Grid and Formviews is with the Visible="true/false" on the aspx page.
The closest I've gotten is loading the page with the FormView not visible and the Gridview visible, but clicking on the linkbutton doesn't "hide" the GridView and "display" the FormView.
I suspect I'm missing something in the VB code, but can't quite figure it out. I know it can be done - I've done it myself before. I just can't find the code I used! Arrrgh!!
Any help would be greatly appreciated!
Thanks
The subject essentially describes what I'm trying to do: I have a GridView and a FormView on a page and I want only the GridView to display on page load and the FormView to only show up when the user clicks a linkbutton, at which time the GridView "disappears".
I've tried messing with the visible properties of both the Grid- and FormViews, while at the same time changing the visible properties on the page load and button click events in the code-behind page:
[BEGIN VB CODE]
Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim formview1 As New FormView
Dim gridview1 As New GridView
gridview1.Visible = True
formview1.Visible = False
End Sub
Protected Sub LinkButton1_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim gridview1 As New GridView
Dim linkbutton1 As New LinkButton
Dim formview1 As New FormView
GridView1.Visible = False
linkbutton1.Visible = False
formview1.Visible = True
End Sub
[END VB CODE]
This code doesn't quite work. The only way I've been able to "hide" and "unhide" the Grid and Formviews is with the Visible="true/false" on the aspx page.
The closest I've gotten is loading the page with the FormView not visible and the Gridview visible, but clicking on the linkbutton doesn't "hide" the GridView and "display" the FormView.
I suspect I'm missing something in the VB code, but can't quite figure it out. I know it can be done - I've done it myself before. I just can't find the code I used! Arrrgh!!
Any help would be greatly appreciated!
Thanks