23 January 2009

Using the Multi-View Control

I had a student the other day who had need of this, and I had to dig it out of the far reaches of my memory (I don't do a lot of individual page/report design work). But It's pretty useful, so I thought I'd toss it out there for everyone else.

There are times when you want to have a lot of information easily accessible on a page within your SharePoint site, but there's too much to put on a single page for whatever reason (not enough screen real estate, visual layout is too cluttered etc.).

There are quite a few ways of coping with this, ranging from creating separate pages to using filters and audience targeting and all sorts of other options. I have found using the MultiView control to be useful, especially when building reports and dashboards.

The MultiView control allows you to create multiple views, putting whatever information and web parts in those views you like and then use navigation controls to switch between them. One gotcha--at a bare minimum you will need to use SharePoint Designer to edit the page that use the controls. Below is a very basic primer on how to create a MultiView section, create the views inside it and use links/buttons to provide some navigation. Keep in mind there are other ways to provide the navigation, but I'm not trying to be comprehensive. I'm going for quick and easy here.

1. Open/create the .aspx page you want to put the control into with SharePoint Designer.

2. Locate the space where you want to put the views.

3. From the "Standard" group in the ASP.NET Controls in the Toolbox, add the MultiView control into that space you identified in Step 2.

4. In the properties for the MultiView control, locate the "ActiveViewIndex" property and set it to 0 (zero). This will display the first view you create. The default value is "-1" which makes all the views hidden.

5. In the white space of the MultiView control, add the number of View controls you need (1 for each view. You will find the View control in the same group as the MultiView control in the Toolbox. The only thing that can be put into the MultiView control are View controls.

6. Each View has an "ID" property that should be set, and will need to be unique with in the set of views for the MultiView control. The default will probably read something like "View1". A more informative name is probably useful.

7. Each View on your page should have some space to insert controls and web parts. This is where you will put your tables/web part zones/web parts/whatever you want in that view.

8. As part of each view you may choose to put your navigation buttons/links. By putting them inside the views, you can make easy use of the builtin properties and methods for navigation that are available to you. There are ways to manage the navigation from outside the MultiView control and the Views, but they are more complex to implement and will require more coding.

9. In each view a Button or LinkButton control for each view. (i.e if you have 3 views inside the MultiView, add three buttons). You may choose to do this once and then copy/paste from one view into the others.

10. For each button, adjust the following properties:
Text: Name of the View the button is going to switch to
CommandName: SwitchViewByID
CommandArgument: ID (the property you set) of the View the button is going to switch to

11. Once complete, save your work and preview the page.

11 comments:

Anonymous said...

Nice fill someone in on and this fill someone in on helped me alot in my college assignement. Thank you on your information.

Anonymous said...

Genial dispatch and this post helped me alot in my college assignement. Say thank you you for your information.

Anonymous said...

Opulently I acquiesce in but I think the brief should prepare more info then it has.

Anonymous said...

Opulently I acquiesce in but I about the list inform should secure more info then it has.

Unknown said...

You write that "There are ways to manage the navigation from outside the MultiView control and the Views, but they are more complex to implement and will require more coding."

Is this possible to do using Sharepoint Designer 2007? If so, can you post a How-to for this approach too?

Anonymous said...

Excuse, that I interrupt you, I too would like to express the opinion.

Anonymous said...

Thanks for your hint!
I made some test much more complicated than yours which all failed.
Your solution is simple and easy to use. The important hint is, that the buttons need to be inside the views.
Thanks a lot!

Anonymous said...

Days & Days I have looked for this answer thank you thank you thank you :-)

Anonymous said...

Thanks, I needed this to work for a project

Pravesh Singh said...

Very informative post. It's really helpful for me and helped me lot to complete my task. Thanks for sharing with us. I had found another nice post over the internet which was also explained very well about View Control in ASP.Net, for more details of this post check out this link...

View Control in asp.net

Thanks everyone for your precious post.

Anonymous said...

Piece of writing writing is also a fun, if you know afterward you
can write if not it is complex to write.

Feel free to visit my blog post ... acoustic guitar chord