protected override void Render(HtmlTextWriter writer) { base.Render(writer); try { if (this.ListToDisplay != null) { SPList selectedList = SPContext.Current.Web.Lists[new Guid(this._listToDisplay)]; SPView defaultView = selectedList.DefaultView; if (this.IsExternalList) { SPViewFieldCollection fields = defaultView.ViewFields; System.Collections.Specialized.StringCollection stringCol = fields.ToStringCollection(); // Nik20121105 - Write the table headers; System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.AppendLine("<table class=\"wet-boew-zebra\">"); sb.Append("<tr>"); foreach (string field in stringCol) { sb.Append("<th>" + field + "</th>"); } sb.Append("</tr>"); foreach (SPListItem item in selectedList.Items) { sb.AppendLine("<tr>"); bool firstCol = true; foreach (string field in stringCol) { if (firstCol) { firstCol = false; sb.AppendLine("<td><a href=\"" + SPContext.Current.Web.Url + "/_layouts/listform.aspx?PageType=4&ListId={" + this._listToDisplay + "}&ID=" + item["BdcIdentity"].ToString() + "\">" + item[field].ToString() + "</a></td>"); } else { sb.AppendLine("<td>" + item[field].ToString() + "</td>"); } } sb.AppendLine("</tr>"); } sb.AppendLine("</table>"); writer.Write(sb.ToString()); } else { writer.Write(defaultView.RenderAsHtml()); } } } catch (Exception ex) { writer.Write(ex.ToString()); } }
public string RenderAsHtml() { return(m_view.RenderAsHtml()); }