try
{
XsltListViewWebPart
lvwp = new XsltListViewWebPart();
SPList
library = SPContext.Current.Web.Lists["Tasks"];
if
(library != null)
{
SPContext.Current.Web.AllowUnsafeUpdates
= true;
//
gets custom view
SPView
view = library.DefaultView;
for
(int i = 0; i < library.Views.Count; i++)
{
if (library.Views[i].BaseViewID == "41")
{
uint rowlimit = 5;
view =
library.Views[i];
view.RowLimit =
rowlimit;
view.Update();
break;
}
}
//
Sets properties of webpart
lvwp.ListName =
library.ID.ToString("B").ToUpper();
lvwp.ViewGuid =
view.ID.ToString("B").ToUpper();
lvwp.XmlDefinition =
view.GetViewXml();
lvwp.SuppressWebPartChrome
= true;
this.pnlList.Controls.Add(lvwp);
}
}
catch
(Exception Ex)
{
Response.Write(Ex.ToString());
}
}
No comments:
Post a Comment