public override string Render() { UserFeedbackDb db = new UserFeedbackDb(); UserFeedbackSubmittedData[] arr = db.FetchAllUserFeedbackSubmittedData(); if (arr.Length == 0) { return("<p><em>No User feedback has been submitted</em></p>"); } StringBuilder html = new StringBuilder(); html.Append("<p>"); html.Append(TABLE_START_HTML); html.Append("<caption><h2>User feedback <a style=\"font-size: small;\" href=\"" + CmsContext.ApplicationPath + "_system/tools/download.ashx?adminTool=" + GetType().Name + "\">(download to Excel file)</a></h2></caption>"); html.Append("<tr>"); html.Append("<th>Submitted</th>"); html.Append("<th>Name</th><th>Email Address</th><th>Location</th><th>Question</th><th>Answer</th><th>ReferringUrl</th>"); html.Append("</tr>"); foreach (UserFeedbackSubmittedData d in arr) { html.Append("<tr>"); html.Append("<td>" + d.dateTimeSubmitted.ToString("yyyy-MM-dd") + "</td>"); html.Append("<td>" + d.Name + "</td><td>" + d.EmailAddress + "</td><td>" + d.Location + "</td><td>" + d.TextAreaQuestion + "</td><td>" + d.TextAreaValue + "</td><td>" + d.ReferringUrl + "</td>"); html.Append("</tr>"); } html.Append("</table>"); html.Append("</p>"); return(html.ToString()); }
/// <summary> /// Select appropriate database table and download the data to the client /// </summary> /// <param name="tool"></param> /// <param name="context"></param> protected void downloadContent(BaseCmsAdminTool tool, HttpContext context) { string fileName = tool.ToString() + "_" + DateTime.Now.ToString("yyyy-MM-dd") + ".xls"; GridView gridview1 = new GridView(); if (tool.GetType().Name.EndsWith("ListUserFeedback")) { gridview1 = new UserFeedbackDb().FetchAllUserFeedbackSubmittedDataAsGrid(); } else if (tool.GetType().Name.EndsWith("ListRegisteredProjects")) { gridview1 = new RegisterProjectDb().fetchAllAsGrid(); } OutputDataSetToExcelFile.OutputToResponse(gridview1, fileName, "", "", context.Response); }