Thomas BP
Thomas BP

Reputation: 1227

how can i show a gridview on a page and then a listview on the same page

Im new to this and need some info. I want to make a gridview and a listview on the same page, but do i same em in 2 functions or 2 subs.

And how do i call the function/sub, when visit the page, the default show is Gridview, and then i have a icon under that, so when i click that its calling the listview function/sub. Or do i call the gridview and listview and then use GridView1.Visible = false or ListView1.Visible = false to show/hide views !?

So. 1. Sub or Function. 2. How do i call the Gridview as default view when first visit, and how do i call the listview, with the icon. If then Else or !?

Im coding in asp.net VB.

Upvotes: 0

Views: 297

Answers (2)

mboldt
mboldt

Reputation: 1825

In your .aspx-file you create both, the ListView and the GridView but set the Visible-Attribute of your ListView to false. In the Click-EventHandler of your icon you can then set the visibility of the ListView to true and the visibility of the GridView to false and vice versa.

Upvotes: 2

Aghilas Yakoub
Aghilas Yakoub

Reputation: 28970

You can use PlaceHolder control

PlaceHolder.Control.Add(YourGridView);

Or

 PlaceHolder.Control.Add(YourListView);

Nota : you can also load two controls and adjust Visible property

Sample :

<asp:PlaceHolder ID="PlaceHolder1" runat="server" /> 
<asp:Button   
         ID="Button1"   
         runat="server"   
         Text="Add Control"   
         OnClick="Button1_Click"  />

Code Behind

protected void Button1_Click(object sender, EventArgs e)  
{  
        var YourGridView = .....;
        PlaceHolder1.Controls.Add(YourGridView);  
}  

Link : http://msdn.microsoft.com/fr-fr/library/system.web.ui.webcontrols.placeholder.aspx

Upvotes: 0

Related Questions