Hey folks!!!
It's been a pretty long time. I've been on a lot of projects in between and have been pretty much heads down since the last post. I figure I'll start off the next few rounds with a use control that across the board called the
List View Control.
The
SharePoint List View control is a very useful control that is leveraged in the ListView
WebPart to display List. It's location is in the common
Microsoft.SharePoint.WebControls namespace and it only needs a 2 properties to really show all of it's value. Internally this control interprets List Views and field values and renders them in a
SPGridView control. It's nice to be able to simply leverage this control without doing all of the work.
Here's a code sample that should explain exactly how to use it:
namespace TAS.Examples
{
class ListViewExample : System.Web.UI.WebControls.WebParts.WebPart
{
Microsoft.SharePoint.WebControls.ListView view;
protected override void CreateChildControls()
{
view = new ListView();
SPList list = SPContext.Current.Web.Lists["
view.ListID = list.ID;
view.ViewID=list.DefaultView.ID;
Controls.Add(view);
}
protected override void RenderContents(writer)
{
view.renderControl(writer);
}
}
}
This is only a light sample of what you can do with this web control. By leveraging this control you know longer have to fight with an
SPGridView Control or leverage the "RenderAsHTML" method of a List just to enable your WebParts and pages to leverage SharePoints Out of the box list capabilities.
Hope this helps,
~:)