I am customizing xsltlist view webpart using c#. I am able to get the results properly till I give the view name to the code. As soon as I give it it's not rendering the data. It's only displaying the grouping in the view. Below is my code for the same. Can anyone let me know what is wrong in this. Here is the code:
[WebBrowsable(true),
Personalizable(PersonalizationScope.Shared),
Category("Custom Properties"),
WebDisplayName("Web Url"),
WebDescription("Enter the Web Url")]
public string WebUrl { get; set; }
[WebBrowsable(true),
Personalizable(PersonalizationScope.Shared),
Category("Custom Properties"),
WebDisplayName("List Name"),
WebDescription("Enter the List Name")]
public string ListName { get; set; }
[WebBrowsable(true),
Personalizable(PersonalizationScope.Shared),
Category("Custom Properties"),
WebDisplayName("View Name"),
WebDescription("Enter the View Name")]
public string ViewName { get; set; }
if (!string.IsNullOrEmpty(ListName))
{
SPList list = web.Lists[ListName.ToString()];
XsltListViewWebPart xsltwp = new XsltListViewWebPart();
xsltwp.ListName = list.ID.ToString("B").ToUpperInvariant();
xsltwp.TitleUrl = list.DefaultViewUrl;
xsltwp.WebId = list.ParentWeb.ID;
xsltwp.Title = list.Title;
xsltwp.ListUrl = list.DefaultViewUrl;
xsltwp.ListId = list.ID;
xsltwp.ChromeType = System.Web.UI.WebControls.WebParts.PartChromeType.None;
if (!string.IsNullOrEmpty(ViewName))
{
SPView defaultView = list.Views[ViewName];
xsltwp.ViewId = Int32.Parse(defaultView.BaseViewID);
xsltwp.ViewGuid = defaultView.ID.ToString("B").ToUpper();
}
//xsltwp.XmlDefinition = view.GetViewXml();
this.Controls.Add(xsltwp);
this.Controls.Add(xsltwp);
}
Thanks in advance.