iTextSharp output to PDF - c#

I've been trying to get this working for a long time now and I was hoping that someone could help me out with this. I am trying to save two ListViews from my ASCX control (incorporated to my ASPX page as follows) to a PDF file. I believe that the problem lies in these two lines of code, as I am getting an 'the document has no pages' error when saving. Any ideas would be greatly appreciated! Thanks in advance...
ListView lv1 = (ListView)TagCloudControl1.FindControl("ListView1");
ListView lv2 = (ListView)TagCloudControl1.FindControl("ListView2");
ASPX page:
<%# Register Src="~/tagcloud.ascx" TagName="TagCloudControl" TagPrefix="TagCloud" %>
...
<TagCloud:TagCloudControl ID="TagCloudControl1" runat="server" />
C#:
private void GeneratePDF(string path, string fileName, bool download, string text) {
var document = new Document();
try{
if (download) {
PdfWriter.GetInstance(document, Response.OutputStream);
} else {
PdfWriter.GetInstance(document, new FileStream(path + fileName, FileMode.Create));
}
StringBuilder strB = new StringBuilder();
document.Open();
if (text.Length.Equals(0)) {
TagCloudControl1.BindTagCloud();
using (StringWriter sWriter = new StringWriter(strB)) {
using (HtmlTextWriter htWriter = new HtmlTextWriter(sWriter)) {
//var lv1 = (TagCloudControl)ListView.FindControl("ListView1");
//var lv2 = (TagCloudControl)ListView.FindControl("ListView2");
ListView lv1 = (ListView)TagCloudControl1.FindControl("ListView1");
ListView lv2 = (ListView)TagCloudControl1.FindControl("ListView2");
lv1.RenderControl(htWriter);
lv2.RenderControl(htWriter);
}
}
} else {
strB.Append(text);
}
using (TextReader sReader = new StringReader(strB.ToString())) {
List<IElement> list = HTMLWorker.ParseToList(sReader, new StyleSheet());
foreach (IElement elm in list) {
document.Add(elm);
}
}
} catch (Exception ee) {
ee.ToString();
} finally {
document.Close();
}
}
protected void GeneratePDFAndDownload (object sender, EventArgs e) {
string fileName = "RetroCloud_" + proj_name + "_" + DateTime.Now.Ticks + ".pdf";
GeneratePDF("", fileName, true, "");
Response.Clear();
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment; filename=" + fileName);
Response.Flush();
Response.End();
}
ASCX Control:
<%# Control Language="C#" AutoEventWireup="true" CodeFile="tagcloud.ascx.cs" Inherits="tagcloud" %>
<div style="padding-left: 25px; padding-right: 25px; text-align: center;">
<asp:listview runat="server" ID="ListView1" ItemPlaceholderID="itemPlaceHolder">
<LayoutTemplate>
<asp:PlaceHolder runat="server" ID="itemPlaceHolder"></asp:PlaceHolder>
</LayoutTemplate>
<ItemTemplate>
<%# Eval("Tag") %>
</ItemTemplate>
<EmptyDataTemplate>
<asp:Label ID="negative_tags" runat="server" style="color: #ff0000;" Text="[NO NEGATIVE TAGS FOUND]"></asp:Label>
</EmptyDataTemplate>
</asp:listview>
</div>
<br />
<div style="padding-left: 25px; padding-right: 25px; text-align: center;">
<asp:listview runat="server" ID="ListView2" ItemPlaceholderID="itemPlaceHolder">
<LayoutTemplate>
<asp:PlaceHolder runat="server" ID="itemPlaceHolder"></asp:PlaceHolder>
</LayoutTemplate>
<ItemTemplate>
<%# Eval("Tag") %>
</ItemTemplate>
<EmptyDataTemplate>
<asp:Label ID="positive_tags" runat="server" style="color: #33cc00;" Text="[NO POSITIVE TAGS FOUND]"></asp:Label>
</EmptyDataTemplate>
</asp:listview>
</div>
ASCX CS FILE:
string proj_id, proj_name, iteration;
protected void Page_Load(object sender, EventArgs e)
{
proj_name = Request.QueryString["project"].ToString();
proj_id = Request.QueryString["id"].ToString();
if (String.IsNullOrEmpty((string)Session["iteration"]))
iteration = "0";
else
iteration = (string)Session["iteration"];
BindTagCloud();
}
private void BindTagCloud()
{
int pro_id = Convert.ToInt32(proj_id);
int iteration_id = Convert.ToInt32(iteration);
....
if (iteration_id != 0)
{
ListView1.DataSource = tagCloudNegativeIteration;
ListView1.DataBind();
ListView2.DataSource = tagCloudPositiveIteration;
ListView2.DataBind();
}
else
{
ListView1.DataSource = tagCloudNegative;
ListView1.DataBind();
ListView2.DataSource = tagCloudPositive;
ListView2.DataBind();
}

"The Document has no pages" means you haven't actually written anything to the Document before calling document.close().
I suspect that if you set a breakpoint at the line where you call document.add(), you'll never hit it.
I suggest you take a long, hard look at the input and output to HTMLWorker.ParseToList(). I doubt it's what you expect.

Related

Multiple upload in c# net 4.0

After saving information from a page in c# net 4.0 I need to add some pics in multiple mode.
I can't use net 4.5.
The problem :
If I open the page with multiple upload in the browser IE 11 this works correctly, and you can select multiple pics to upload.
If I open the same page as multiple upload in a window popup on IE 11, you can't select multiple pics to upload, but only a pic.
What's the problem ?
My code below, thank you in advance.
.aspx markup (Default.aspx)
<form id="form1" runat="server">
<div>
<asp:Panel ID="upload01" runat="server" CssClass="pure-form pure-form-stacked">
<fieldset style="margin-left: 50px">
<legend style="font-weight: bold; color: Red; margin-left: 10px;">PICS</legend>
<div class="pure-g">
<div class="pure-u-1 pure-u-md-1-3">
<label for="Pics">Pics</label>
<p>
<asp:FileUpload ID="fileUpload" multiple="true" runat="server" />
</p>
<p>
<p>
<asp:Button ID="btUpload" Text="Upload Files"
OnClick="Upload_Files" runat="server" />
</p>
</p>
<p>
<asp:Label ID="lblFileList" runat="server"></asp:Label>
</p>
<p>
<asp:Label ID="lblUploadStatus" runat="server"></asp:Label>
</p>
<p>
<asp:Label ID="lblFailedStatus" runat="server"></asp:Label>
</p>
</div>
</div>
</fieldset>
</asp:Panel>
</div>
</form>
.cs code-behind
protected void btnSave_Click(object sender, ImageClickEventArgs e)
{
ScriptManager.RegisterStartupScript(this, typeof(string), "OPEN_WINDOW", "var Mleft = (screen.width/2)-(760/2);var Mtop = (screen.height/2)-(700/2);window.open( 'Default.aspx', null, 'height=700,width=760,status=yes,toolbar=no,scrollbars=yes,menubar=no,location=no,top=\'+Mtop+\', left=\'+Mleft+\'' );", true);
}
EDIT #1
protected void Upload_Files(object sender, EventArgs e)
{
if (upload01.HasFile) // CHECK IF ANY FILE HAS BEEN SELECTED.
{
int iUploadedCnt = 0;
int iFailedCnt = 0;
HttpFileCollection hfc = Request.Files;
lblFileList.Text = "Select <b>" + hfc.Count + "</b> file(s)";
if (hfc.Count <= 10) // 10 FILES RESTRICTION.
{
for (int i = 0; i <= hfc.Count - 1; i++)
{
HttpPostedFile hpf = hfc[i];
if (hpf.ContentLength > 0)
{
if (!File.Exists(Server.MapPath("\\images\\") +
Path.GetFileName(hpf.FileName)))
{
DirectoryInfo objDir =
new DirectoryInfo(Server.MapPath("\\images\\"));
string sFileName = Path.GetFileName(hpf.FileName);
string sFileExt = Path.GetExtension(hpf.FileName);
// CHECK FOR DUPLICATE FILES.
FileInfo[] objFI =
objDir.GetFiles(sFileName.Replace(sFileExt, "") + ".*");
if (objFI.Length > 0)
{
// CHECK IF FILE WITH THE SAME NAME EXISTS (IGNORING THE EXTENTIONS).
foreach (FileInfo file in objFI)
{
string sFileName1 = objFI[0].Name;
string sFileExt1 = Path.GetExtension(objFI[0].Name);
if (sFileName1.Replace(sFileExt1, "") ==
sFileName.Replace(sFileExt, ""))
{
iFailedCnt += 1; // NOT ALLOWING DUPLICATE.
break;
}
}
}
else
{
// SAVE THE FILE IN A FOLDER.
hpf.SaveAs(Server.MapPath("\\images\\") +
Path.GetFileName(hpf.FileName));
iUploadedCnt += 1;
}
}
}
}
lblUploadStatus.Text = "<b>" + iUploadedCnt + "</b> file(s) Uploaded.";
lblFailedStatus.Text = "<b>" + iFailedCnt +
"</b> duplicate file(s) could not be uploaded.";
}
else lblUploadStatus.Text = "Max. 10 files allowed.";
}
else lblUploadStatus.Text = "No files selected.";
}
I think your approach is wrong for this problem
Please see this, I hope this help.
Click here

ASP button not posting back after exporting a pdf from ashx using response.write

I am exporting a pdf from a json string from database. My export buttons are in a gridview control - Image buttons. I am using a Handler (ashx) file for exporting.
The problem is, after exporting the buttons on the page (one button and one command field) are not posting back. My handler code and aspx code are below
Handler
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI.WebControls;
using iTextSharp.text;
using iTextSharp.text.pdf;
using iTextSharp.text.html;
using iTextSharp.text.html.simpleparser;
using System.IO;
using System.Web.UI;
using System.Data;
using GE.MSA.DataQuality.DataAccess;
using GE.MSA.DataQuality.DataAccess.Authentication;
using GE.MSA.DataQuality.DataAccess.EntityModel;
using Newtonsoft.Json;
namespace GE.MSA.DataQuality.Web
{
/// <summary>
/// Summary description for CreatePDF
/// </summary>
public class CreatePDF : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
//context.Response.ContentType = "text/plain";
//context.Response.Write("Hello World");
int _id = Convert.ToInt32(context.Request.QueryString["Id"]);
string _report = context.Request.QueryString["Report"];
string _lockedfrom = context.Request.QueryString["LockedFrom"];
string _lockedto = context.Request.QueryString["LockedTo"];
string _docheader = (_report == "CostServiceReport" ? "Cost & Service Report - " : "Service Report - ") + "Locked from : " + _lockedfrom + " to " + _lockedto;
string _doctitle = _report + "-" + _lockedfrom + "-" + _lockedto + ".pdf";
DataTable _PDFReport = new DataTable();
if (_report == "CostServiceReport")
{
using (var db = new dbReferenceTablesEntities())
{
string csr = (from i in db.CS_Billing_LockPeriod
where i.ID == _id
select i.CostServiceReport).FirstOrDefault().ToString();
_PDFReport = (DataTable)JsonConvert.DeserializeObject(csr, _PDFReport.GetType());
}
}
else
{
if (_report == "ServiceReport")
{
using (var db = new dbReferenceTablesEntities())
{
string sr = (from i in db.CS_Billing_LockPeriod
where i.ID == _id
select i.ServiceReport).FirstOrDefault().ToString();
_PDFReport = (DataTable)JsonConvert.DeserializeObject(sr, _PDFReport.GetType());
}
}
}
Document pdfDoc = new Document(PageSize.A3, 20, 20, 20, 20);
pdfDoc.SetPageSize(iTextSharp.text.PageSize.A3.Rotate());
try
{
PdfWriter.GetInstance(pdfDoc, System.Web.HttpContext.Current.Response.OutputStream);
pdfDoc.Open();
Chunk c = new Chunk("" + _docheader + "", FontFactory.GetFont("Verdana", 15));
Paragraph p = new Paragraph();
p.Alignment = Element.ALIGN_CENTER;
p.Add(c);
pdfDoc.Add(p);
string clientLogo = context.Server.MapPath(".") + "/images/abc.png";
string imageFilePath = context.Server.MapPath(".") + "/images/abc.png";
iTextSharp.text.Image jpg = iTextSharp.text.Image.GetInstance(imageFilePath);
//Resize image depend upon your need
jpg.ScaleToFit(60f, 40f);
//Give space before image
jpg.SpacingBefore = 0f;
//Give some space after the image
jpg.SpacingAfter = 1f;
jpg.Alignment = Element.HEADER;
pdfDoc.Add(jpg);
Font font8 = FontFactory.GetFont("ARIAL", 7);
DataTable dt = _PDFReport;
if (dt != null & dt.Rows.Count > 0)
{
//Craete instance of the pdf table and set the number of column in that table
PdfPTable PdfTable = new PdfPTable(dt.Columns.Count);
PdfTable.HeaderRows = 1;
PdfPCell PdfPCell = null;
for (int i = 0; i < dt.Columns.Count; i++)
{
PdfPCell = new PdfPCell(new Phrase(new Chunk(dt.Columns[i].ColumnName.ToString(), FontFactory.GetFont("Verdana", 12))));
PdfPCell.HorizontalAlignment = Element.ALIGN_CENTER;
PdfPCell.VerticalAlignment = Element.ALIGN_MIDDLE;
PdfPCell.BackgroundColor = new Color(109, 159, 213);
PdfTable.AddCell(PdfPCell);
}
for (int rows = 0; rows < dt.Rows.Count; rows++)
{
for (int column = 0; column < dt.Columns.Count; column++)
{
PdfPCell = new PdfPCell(new Phrase(new Chunk(dt.Rows[rows][column].ToString(), font8)));
PdfTable.AddCell(PdfPCell);
}
}
//PdfTable.SpacingBefore = 15f; // Give some space after the text or it may overlap the table
pdfDoc.Add(PdfTable); // add pdf table to the document
}
pdfDoc.Close();
context.Response.ContentType = "application/pdf";
context.Response.AddHeader("content-disposition", "attachment; filename= " + _doctitle);
System.Web.HttpContext.Current.Response.Write(pdfDoc);
context.Response.Flush();
HttpContext.Current.ApplicationInstance.CompleteRequest();
}
catch (DocumentException de)
{
System.Web.HttpContext.Current.Response.Write(de.Message);
}
catch (IOException ioEx)
{
System.Web.HttpContext.Current.Response.Write(ioEx.Message);
}
catch (Exception ex)
{
System.Web.HttpContext.Current.Response.Write(ex.Message);
}
}
public bool IsReusable
{
get
{
return false;
}
}
}
}
ASPX Page
<%# Page Title="" Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true" CodeBehind="LockForcing.aspx.cs" Inherits="GE.MSA.DataQuality.Web.LockForcing" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<asp:ScriptManager ID="scriptManager1" runat="server"></asp:ScriptManager>
<asp:UpdatePanel ID="up1" runat="server">
<ContentTemplate>
<h2>Lock Force Calculation</h2>
<div>
<fieldset>
<legend>Set Lock Period</legend>
<table>
<tr>
<td>
<label>Start Month</label></td>
<td>
<asp:DropDownList ID="ddlStartMonth" runat="server" Width="100%">
<asp:ListItem>01</asp:ListItem>
<asp:ListItem>02</asp:ListItem>
<asp:ListItem>03</asp:ListItem>
<asp:ListItem>04</asp:ListItem>
<asp:ListItem>05</asp:ListItem>
<asp:ListItem>06</asp:ListItem>
<asp:ListItem>07</asp:ListItem>
<asp:ListItem>08</asp:ListItem>
<asp:ListItem>09</asp:ListItem>
<asp:ListItem>10</asp:ListItem>
<asp:ListItem>11</asp:ListItem>
<asp:ListItem>12</asp:ListItem>
</asp:DropDownList></li></td>
<td></td>
<td>
<label>Start Year</label></td>
<td>
<asp:DropDownList ID="ddlStartYear" runat="server" Width="100%">
</asp:DropDownList></td>
</tr>
<tr>
<td>
<label>End Month</label></td>
<td>
<asp:DropDownList ID="ddlEndMonth" runat="server" Width="100%">
<asp:ListItem>01</asp:ListItem>
<asp:ListItem>02</asp:ListItem>
<asp:ListItem>03</asp:ListItem>
<asp:ListItem>04</asp:ListItem>
<asp:ListItem>05</asp:ListItem>
<asp:ListItem>06</asp:ListItem>
<asp:ListItem>07</asp:ListItem>
<asp:ListItem>08</asp:ListItem>
<asp:ListItem>09</asp:ListItem>
<asp:ListItem>10</asp:ListItem>
<asp:ListItem>11</asp:ListItem>
<asp:ListItem>12</asp:ListItem>
</asp:DropDownList></td>
<td></td>
<td>
<label>End Year</label></td>
<td>
<asp:DropDownList ID="ddlEndYear" runat="server" Width="100%">
</asp:DropDownList></td>
<td>
<asp:Button ID="btnLock" runat="server" Width="120px" Text="Lock" CssClass="submitButton"
BorderStyle="None" OnClick="btnLock_Click" />
</td>
<td>
<asp:Label runat="server" ID="lblLockMessage"></asp:Label>
<asp:Timer ID="Timer1" runat="server" Interval="5000" Enabled="false" OnTick="Timer1_Tick"></asp:Timer>
</td>
</tr>
</table>
</fieldset>
</div>
<div>
<table width="100%">
<tr>
<td>
<label>Lock Period Details</label>
</td>
<td align="right">
<asp:Label runat="server" ID="lblmsg"></asp:Label>
</td>
</tr>
<tr>
<td colspan="2">
<asp:GridView ID="gvLockPeriod" runat="server" AutoGenerateColumns="false" CssClass="mGrid" OnRowDeleting="gvLockPeriod_RowDeleting"
DataKeyNames="Id">
<Columns>
<asp:CommandField ShowDeleteButton="true" ControlStyle-ForeColor="darkcyan" DeleteText="Unlock"></asp:CommandField>
<asp:BoundField DataField="FromDate" HeaderText="FromDate" />
<asp:BoundField DataField="ToDate" HeaderText="ToDate" />
<asp:TemplateField HeaderText="Cost&ServiceReport">
<ItemTemplate>
<asp:ImageButton ImageUrl="~/images/Pdf-16.png" runat="server" ToolTip="Download Cost & Service Report"
Visible='<%# Convert.ToBoolean(Eval("CostServiceReport")) %>'
PostBackUrl='<%#"CreatePDF.ashx?id="+Eval("Id")+"&Report=CostServiceReport"+"&LockedFrom="+Eval("fromdate")+"&LockedTo="+Eval("todate")+""%>' />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="ServiceReport">
<ItemTemplate>
<asp:ImageButton ImageUrl="~/images/Pdf-16.png" runat="server" ToolTip="Download Service Report"
Visible='<%# Convert.ToBoolean(Eval("ServiceReport")) %>'
PostBackUrl='<%#"CreatePDF.ashx?id="+Eval("Id")+"&Report=ServiceReport"+"&LockedFrom="+Eval("fromdate")+"&LockedTo="+Eval("todate")+""%>' />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="ModifiedBy" HeaderText="CreatedUser" />
<asp:BoundField DataField="ModifiedDate" HeaderText="CreatedDate" />
</Columns>
</asp:GridView>
</td>
</tr>
</table>
</div>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdateProgress ID="UpdateProgress1" runat="server">
<ProgressTemplate>
<div class="overlays" />
<div style="font-weight: bold; align-content: center" class="overlayContents">
<asp:Image ID="aspImg1" runat="server" ImageUrl="~/images/ajax-loader.GIF" />
</div>
</ProgressTemplate>
</asp:UpdateProgress>
</asp:Content>
After flushing the response call the response end method.
context.Response.Flush();
System.Web.HttpContext.Current.Response.End();

Image is not display in repeater in asp.net

In my website i am saving data in xml using html editor. When i add a picture before the content means on the top of the content and save it in xml.Now the problem is this that when i am trying to get result from xml to repeater control then image which is on the top of the content is giving me blank result.
Here is the code which i am using for save data in xml
int date = DateTime.Now.Day;
int month = DateTime.Now.Month;
int year = DateTime.Now.Year;
String File = Server.MapPath("~/Data/BlogContent.xml");
int newid;
XDocument doc = XDocument.Load(File);
XElement root = doc.Root;
string id = root.Elements("post").Last().ToString();
XmlDocument pacXML = new XmlDocument();
pacXML.Load(new StringReader(id));
XmlNode xmlnode1;
xmlnode1 = pacXML.DocumentElement.ChildNodes.Item(1);
String stCode = Convert.ToString(pacXML.DocumentElement.ChildNodes.Item(0).InnerText).Trim();
if (xmlnode1 == null)
{
newid = 1;
}
newid = Convert.ToInt32(stCode.ToString()) + 1;
XmlDocument xdoc = new XmlDocument();
xdoc.Load(File);
XmlNode xnode = xdoc.SelectSingleNode("content");
XmlNode xrnode = xnode.AppendChild(xdoc.CreateNode(XmlNodeType.Element, "post", ""));
xrnode.AppendChild(xdoc.CreateNode(XmlNodeType.Element, "id", "")).InnerText = newid.ToString();
xrnode.AppendChild(xdoc.CreateNode(XmlNodeType.Element, "title", "")).InnerText = TextBox1.Text;
xrnode.AppendChild(xdoc.CreateNode(XmlNodeType.Element, "Discription", "")).InnerText = Editor.Text;
xrnode.AppendChild(xdoc.CreateNode(XmlNodeType.Element, "dt", "")).InnerText = date.ToString();
xrnode.AppendChild(xdoc.CreateNode(XmlNodeType.Element, "mnt", "")).InnerText = month.ToString();
xrnode.AppendChild(xdoc.CreateNode(XmlNodeType.Element, "yr", "")).InnerText = year.ToString();
xrnode.AppendChild(xdoc.CreateNode(XmlNodeType.Element, "PostDate", "")).InnerText = DateTime.Now.ToString("MM/dd/yyyy");
xdoc.Save(File);
Editor.Text = string.Empty;
TextBox1.Text = string.Empty;
and it is the code of display data in repeater
PagedDataSource page = new PagedDataSource();
page.AllowCustomPaging = true;
page.AllowPaging = true;
DataTable dtv = (DataTable)ViewState["Mytable"];
DataView dv = new DataView();
dv = dtv.DefaultView;
dv.Sort = dtv.Columns["id"].ColumnName;
dv.Sort += " Desc";
dv.RowFilter = "id>=" + pageSize + " AND " + "id<=" + take;
page.DataSource = dv;
page.PageSize = psize;
Repeater1.DataSource = page;
Repeater1.DataBind();
if (!IsPostBack)
{
int rowcount = dtv.Rows.Count;
CreatePagingControl(rowcount);
}
here repeater is binding
<asp:Repeater ID="Repeater1" runat="server"
onitemcommand="Repeater1_ItemCommand"
onitemdatabound="Repeater1_ItemDataBound1" >
<ItemTemplate>
<ul class="articles box">
<li>
<asp:Label ID="Label1" runat="server" Text='<%#Eval("id") %>' color="white"></asp:Label>
<h2><a href='<%# Eval("id","PostComment.aspx?id={0}") %>'> <asp:Label ID="Label3" runat="server" Text='<%#Eval("title ") %>'></asp:Label></a></h2>
<div class="article-info box">
<p class="f-right"><asp:Label ID="Label4" runat="server" Text="Label"></asp:Label></p>
<p class="f-left">
Post Date:<asp:Label ID="Label2" runat="server" Text='<%#Eval("postdate") %>'></asp:Label>
</div>
<p> <asp:Label ID="Label5" runat="server" Text="this is the blog of journeycook.com website" Visible="false"></asp:Label>
<asp:Label ID="lblcontent" runat="server" Text='<%# Limit(Eval("Discription"),1000) %>'></asp:Label></p>
<p class="more"><asp:HyperLink ID="ReadMoreLinkButton" runat="server" NavigateUrl='<%# Eval("id","~/PostComment.aspx?id={0}") %>'>Read More</asp:HyperLink></p>
<%-- <asp:LinkButton ID="ReadMoreLinkButton" runat="server"
Text="Read More"
NavigateUrl='<%# Eval("id","~/PostComment.aspx?id={0}") %>'></asp:LinkButton>--%><br /><br /><br />
</li>
</ul>
</ItemTemplate>
</asp:Repeater>
I hope you understand what is my problem

Repeater Not showing any data in asp.net application on hosting server

I am using repeater which works fine on local system but not working when uploaded on web server. And its also working fine when connected to the server from our local code..
The following is the page code and code behind. And repeated contains textbox, dropdown list which loads dynamically at the run time
page code:
<%# Control Language="C#" AutoEventWireup="true" CodeFile="UC_TopicSchedulingNew.ascx.cs" Inherits="Scheduling_UC_TopicSchedulingNew" %>
<%# Register Assembly="XtendedControls" Namespace="XtendedControls" TagPrefix="cc1" %>
<%# Register Namespace="AjaxControlToolkit" Assembly="AjaxControlToolkit" TagPrefix="ajax" %>
<%# Register Src="~/SelectPopup/UC_PopupDropdown.ascx" TagName="PopupSelectAny" TagPrefix="PD" %>
<script type="text/javascript">
function pageLoad() {
$('.DatepickerInput').datepicker({ changeMonth: true, changeYear: true, yearRange: '1950:2050', dateFormat: 'dd/mm/yy', showButtonPanel: true });
}
$(document).ready(function () {
$('.DatepickerInput').datepicker({ changeMonth: true, changeYear: true, yearRange: '1950:2050', dateFormat: 'dd/mm/yy', showButtonPanel: true });
});
</script>
<asp:UpdatePanel runat="server" ID="updtsForm">
<ContentTemplate>
<div style="width: 100%; float: left; padding-left: 10px;">
<div style="width: 20%; float: left; padding-left: 10px;">
<div class="editor-label" style="font-weight: bold;">
Branch : <b style="color: Red;">*</b>
</div>
<div class="editor-field">
<asp:TextBox ID="txtBranchs" runat="server" CssClass="txt-drop-down" TabIndex="1"
ReadOnly="true" Width="16px"></asp:TextBox><cc1:XBranch ID="XBranch" runat="server"
TabIndex="-1"></cc1:XBranch>
<ajax:PopupControlExtender ID="PopExBranchs" runat="server" TargetControlID="txtBranchs"
BehaviorID="exbranchClose" PopupControlID="pnlListBranchs" CommitProperty="value"
Position="Bottom" OffsetY="2" />
<asp:HiddenField ID="HFBranchID" runat="server" />
</div>
<br />
<div class="editor-label" style="font-weight: bold;">
Course : <b style="color: Red;">*</b>
</div>
<div class="editor-field">
<asp:TextBox ID="txtCourse" runat="server" CssClass="txt-drop-down" TabIndex="2"
ReadOnly="true" Width="16px"></asp:TextBox><cc1:XCourse ID="XCourse" runat="server"
TabIndex="-1"></cc1:XCourse>
<ajax:PopupControlExtender ID="PopExCourse" runat="server" TargetControlID="txtCourse"
BehaviorID="excourseClose" PopupControlID="pnlListCourse" CommitProperty="value"
Position="Bottom" OffsetY="2" />
<asp:HiddenField ID="HFCourseID" runat="server" />
</div>
<br />
<div class="editor-label" style="font-weight: bold;">
Batch :
</div>
<div class="editor-field">
<asp:TextBox ID="txtBatch" runat="server" CssClass="txt-drop-down" TabIndex="44"
ReadOnly="true" Width="16px"></asp:TextBox><cc1:XTextBox ID="XBatch" runat="server"
TabIndex="-1"></cc1:XTextBox>
<ajax:PopupControlExtender ID="PopExBatch" runat="server" TargetControlID="txtBatch"
BehaviorID="exBatchClose" PopupControlID="pnlListBatch" CommitProperty="value"
Position="Bottom" OffsetY="2" />
<asp:HiddenField ID="HFBatchID" runat="server" Value="0" />
<asp:HiddenField ID="HFBatchClRoom" runat="server" />
</div>
<br />
</div>
<div style="width: 20%; float: left; padding-left: 10px;">
<div class="editor-label" style="font-weight: bold;">
Time :
</div>
<div class="editor-field">
<cc1:XTextBox ID="XTime" runat="server" TabIndex="-1" Width="149px"></cc1:XTextBox>
</div>
<br />
<div class="editor-label" style="font-weight: bold;">
Start Date :
</div>
<div class="editor-field">
<cc1:XTextBox ID="XStartDate" runat="server" TabIndex="-1" Width="149px"></cc1:XTextBox>
</div>
<br />
<div class="editor-label" style="font-weight: bold;">
End Date :
</div>
<div class="editor-field">
<cc1:XTextBox ID="XEndDate" runat="server" TabIndex="-1" Width="149px"></cc1:XTextBox>
</div>
<br />
</div>
<div style="width: 50%; float: left; padding-left: 10px;">
<div class="editor-label" style="font-weight: bold;">
Curriculum :
</div>
<div class="editor-field">
<asp:TextBox ID="txtCurriculum" runat="server" CssClass="txt-drop-down" TabIndex="44"
ReadOnly="true" Width="16px"></asp:TextBox><cc1:XCurriculum ID="XCurriculum" runat="server"
TabIndex="-1"></cc1:XCurriculum>
<ajax:PopupControlExtender ID="popExCurriculum" runat="server" TargetControlID="txtCurriculum"
BehaviorID="exCurriculumClose" PopupControlID="pnlListCurriculum" CommitProperty="value"
Position="Bottom" OffsetY="2" />
<asp:HiddenField ID="HFCurriculumID" runat="server" Value="0" />
</div>
<br />
<div class="editor-label" style="font-weight: bold;">
Faculty :
</div>
<div class="editor-field">
<asp:TextBox ID="txtFaculty" runat="server" CssClass="txt-drop-down" TabIndex="44"
ReadOnly="true" Width="16px"></asp:TextBox><cc1:XFaculty ID="XFaculty" runat="server"
TabIndex="-1"></cc1:XFaculty>
<ajax:PopupControlExtender ID="PopExFaculty" runat="server" TargetControlID="txtFaculty"
BehaviorID="exFacultyClose" PopupControlID="pnlListFaculty" CommitProperty="value"
Position="Bottom" OffsetY="2" />
<asp:HiddenField ID="HFFacultyID" runat="server" Value="0" />
</div>
<br />
<div class="editor-label" style="font-weight: bold;">
<asp:Button ID="btnGet" runat="server" Text="Get Topics"
onclick="btnGet_Click" />
</div>
</div>
</div>
<br />
<br />
<b>Topics : </b>
<br />
<br />
<div style="width: 100%; float: left; height: 250px; overflow: scroll; border: solid 1px gray;">
<asp:Repeater ID="rptTopics" runat="server">
<HeaderTemplate>
<table class="grid-new" cellpadding="0" cellspacing="0" id="table1">
<thead>
<th class="myheadth" style="text-align: left; width: 40px;">
Srno.
</th>
<th class="myheadth" style="text-align: left; width: 300px;">
Topic
</th>
<th class="myheadth" style="text-align: left; width: 80px;">
Topic Date
</th>
<th class="myheadth" style="text-align: left; width: 60px;">
St. Time
</th>
<th class="myheadth" style="text-align: left; width: 60px;">
En. Time
</th>
<th class="myheadth" style="text-align: left;">
Classroom
</th>
</thead>
<tbody>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td style="text-align: left; width: 40px;">
<%#Container.ItemIndex+1 %>
</td>
<td style="text-align: left; width: 300px;">
<asp:Label ID="lblID" runat="server" Text='<%#Eval("ID")%>' Visible="false"></asp:Label>
<%#Eval("TopicName")%>
</td>
<td style="text-align: left; width: 80px;">
<div id="DatepickerDiv" class="demo">
<asp:TextBox ID="txtTopicDate" runat="server" CssClass="DatepickerInput" Font-Names="Verdana"
TabIndex="5" Font-Size="11px" Width="70px" Style="border: solid 1px gray;"></asp:TextBox>
</div>
</td>
<td style="text-align: left; width: 60px;">
<cc1:XStartTime ID="XStartTime" runat="server" Width="50px"></cc1:XStartTime>
</td>
<td style="text-align: left; width: 60px;">
<cc1:XEndTime ID="XEndTime" runat="server" Width="50px"></cc1:XEndTime>
</td>
<td style="text-align: left;">
<asp:DropDownList ID="ddlListView" runat="server">
</asp:DropDownList>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</tbody> </table>
</FooterTemplate>
</asp:Repeater>
</div>
<div style="width:100%; float:left; padding-top:20px;">
<asp:Button ID="btnSave" runat="server" Text="Save" Width="70px" OnClick="btnSave_Click" />
</div>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel runat="server" ID="updPanels">
<ContentTemplate>
<asp:Panel ID="pnlListBranchs" runat="server" BackColor="White" ForeColor="Black"
Width="300px" Height="250px" ScrollBars="Vertical" BorderStyle="Solid" BorderWidth="1px"
BorderColor="Gray">
<PD:PopupSelectAny ID="pdBranchs" runat="server" />
</asp:Panel>
<asp:Panel ID="pnlListCourse" runat="server" BackColor="White" ForeColor="Black"
Width="300px" Height="250px" ScrollBars="Vertical" BorderStyle="Solid" BorderWidth="1px"
BorderColor="Gray">
<PD:PopupSelectAny ID="pdCourse" runat="server" />
</asp:Panel>
<asp:Panel ID="pnlListBatch" runat="server" BackColor="White" ForeColor="Black" Width="300px"
Height="250px" ScrollBars="Vertical" BorderStyle="Solid" BorderWidth="1px" BorderColor="Gray">
<PD:PopupSelectAny ID="pdBatch" runat="server" />
</asp:Panel>
<asp:Panel ID="pnlListCurriculum" runat="server" BackColor="White" ForeColor="Black"
Width="300px" Height="250px" ScrollBars="Vertical" BorderStyle="Solid" BorderWidth="1px"
BorderColor="Gray">
<PD:PopupSelectAny ID="pdCurriculum" runat="server" />
</asp:Panel>
<asp:Panel ID="pnlListFaculty" runat="server" BackColor="White" ForeColor="Black"
Width="300px" Height="250px" ScrollBars="Vertical" BorderStyle="Solid" BorderWidth="1px"
BorderColor="Gray">
<PD:PopupSelectAny ID="pdFaculty" runat="server" />
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
Code Behind:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
public partial class Scheduling_UC_TopicSchedulingNew : System.Web.UI.UserControl
{
delegate void dlgTsBranchs();
delegate void dlgTsClassrooms();
delegate void dlgTsCourses();
delegate void dlgTsBatches();
delegate void dlgTsCurriculums();
delegate void dlgTsFaculties();
protected void Page_Load(object sender, EventArgs e)
{
this.pdBranchs.dlgSelectRecords += new dlgSelectRecords(pdBranchs_dlgSelectRecords);
dlgTsBranchs dlgTsBranchs = new dlgTsBranchs(getBranchs);
this.pdBranchs.PageMethodWithListRecords = dlgTsBranchs;
this.pdCourse.dlgSelectRecords += new dlgSelectRecords(pdCourse_dlgSelectRecords);
dlgTsCourses dlgTsCourses = new dlgTsCourses(getCourses);
this.pdCourse.PageMethodWithListRecords = dlgTsCourses;
this.pdFaculty.dlgSelectRecords += new dlgSelectRecords(pdFaculty_dlgSelectRecords);
dlgTsFaculties dlgTsFaculties = new dlgTsFaculties(getFaculties);
this.pdFaculty.PageMethodWithListRecords = dlgTsFaculties;
this.pdBatch.dlgSelectRecords += new dlgSelectRecords(pdBatch_dlgSelectRecords);
dlgTsBatches dlgAdBatches = new dlgTsBatches(getBatches);
this.pdBatch.PageMethodWithListRecords = dlgAdBatches;
this.pdCurriculum.dlgSelectRecords += new dlgSelectRecords(pdCurriculum_dlgSelectRecords);
dlgTsCurriculums dlgTsCurriculums = new dlgTsCurriculums(getCurriculum);
this.pdCurriculum.PageMethodWithListRecords = dlgTsCurriculums;
if (!IsPostBack)
{
disbleEnterKeyForTextBoxes();
}
}
public void disbleEnterKeyForTextBoxes()
{
XTime.Attributes.Add("onkeydown", "return (event.keyCode!=13);");
}
void pdFaculty_dlgSelectRecords(object source, RepeaterCommandEventArgs e, string selval)
{
String[] Myvals = selval.Split('\t');
XFaculty.Text = Myvals[0].ToString();
HFFacultyID.Value = Myvals[1].ToString();
PopExFaculty.Cancel();
}
void pdCurriculum_dlgSelectRecords(object source, RepeaterCommandEventArgs e, string selval)
{
String[] Myvals = selval.Split('\t');
XCurriculum.Text = Myvals[0].ToString();
HFCurriculumID.Value = Myvals[1].ToString();
popExCurriculum.Cancel();
getFaculties();
XFaculty.Text = "";
HFFacultyID.Value = "0";
rptTopics.DataSource = null;
rptTopics.DataBind();
}
void pdBatch_dlgSelectRecords(object source, RepeaterCommandEventArgs e, string selval)
{
String[] Myvals = selval.Split('\t');
XBatch.Text = Myvals[0].ToString();
HFBatchID.Value = Myvals[1].ToString();
PopExBatch.Cancel();
Models.Batch objBatch = new BLL.Batch().OpenByID(HFBatchID.Value);
XTime.Text = objBatch.Time;
XStartDate.Text = objBatch.StDate;
XEndDate.Text = objBatch.EnDate;
HFBatchClRoom.Value = objBatch.ClassRoomID.ToString();
getCurriculum();
XCurriculum.Text = "";
HFCurriculumID.Value = "0";
XFaculty.Text = "";
HFFacultyID.Value = "0";
rptTopics.DataSource = null;
rptTopics.DataBind();
}
void pdCourse_dlgSelectRecords(object source, RepeaterCommandEventArgs e, string selval)
{
String[] Myvals = selval.Split('\t');
XCourse.Text = Myvals[0].ToString();
HFCourseID.Value = Myvals[1].ToString();
PopExCourse.Cancel();
XBatch.Text = "";
HFBatchID.Value = "0";
XTime.Text = "";
XStartDate.Text = "";
XEndDate.Text = "";
getBatches();
XCurriculum.Text = "";
HFCurriculumID.Value = "0";
XFaculty.Text = "";
HFFacultyID.Value = "0";
rptTopics.DataSource = null;
rptTopics.DataBind();
}
void pdBranchs_dlgSelectRecords(object source, RepeaterCommandEventArgs e, string selval)
{
String[] Myvals = selval.Split('\t');
XBranch.Text = Myvals[0].ToString();
HFBranchID.Value = Myvals[1].ToString();
PopExBranchs.Cancel();
getCourses();
XCourse.Text = "";
HFCourseID.Value = "0";
XBatch.Text = "";
HFBatchID.Value = "0";
XTime.Text = "";
XStartDate.Text = "";
XEndDate.Text = "";
XCurriculum.Text = "";
HFCurriculumID.Value = "0";
XFaculty.Text = "";
HFFacultyID.Value = "0";
rptTopics.DataSource = null;
rptTopics.DataBind();
}
public void getBranchs()
{
try
{
Type newClass = typeof(PopupListSelect.Branch);
Repeater nlpListview = (Repeater)pdBranchs.FindControl("gvpbList");
object created = Activator.CreateInstance(newClass, Session["User"].ToString(), Session["DesigID"].ToString(), nlpListview);
}
catch
{
}
}
public void getCourses()
{
try
{
Type newClass = typeof(PopupListSelect.Course);
Repeater nlpListview = (Repeater)pdCourse.FindControl("gvpbList");
object created = Activator.CreateInstance(newClass, HFBranchID.Value, nlpListview);
}
catch
{
}
}
public void getBatches()
{
try
{
if (Session["DesigID"].Equals("6") || Session["DesigID"].Equals("7"))
{
Type newClass = typeof(PopupListSelect.Batch);
Repeater nlpListview = (Repeater)pdBatch.FindControl("gvpbList");
object created = Activator.CreateInstance(newClass, HFBranchID.Value, HFCourseID.Value, Session["User"].ToString(), nlpListview);
}
else
{
Type newClass = typeof(PopupListSelect.Batch);
Repeater nlpListview = (Repeater)pdBatch.FindControl("gvpbList");
object created = Activator.CreateInstance(newClass, HFBranchID.Value, HFCourseID.Value, nlpListview);
}
}
catch
{
}
}
public void getCurriculum()
{
try
{
Type newClass = typeof(PopupListSelect.Curriculum);
Repeater nlpListview = (Repeater)pdCurriculum.FindControl("gvpbList");
object created = Activator.CreateInstance(newClass, nlpListview, HFBatchID.Value);
}
catch
{
}
}
public void getFaculties()
{
try
{
Type newClass = typeof(PopupListSelect.Faculties);
Repeater nlpListview = (Repeater)pdFaculty.FindControl("gvpbList");
object created = Activator.CreateInstance(newClass, HFBranchID.Value, HFCurriculumID.Value, HFBatchID.Value, nlpListview);
}
catch
{
}
}
public void getTopics()
{
try
{
Type newClass = typeof(PopupListSelect.Topics);
object created = Activator.CreateInstance(newClass, HFCurriculumID.Value, rptTopics);
String[] TimeVals = XTime.Text.Split('-');
foreach (RepeaterItem itm in rptTopics.Items)
{
TextBox XStartTime = (TextBox)itm.FindControl("XStartTime");
TextBox XEndTime = (TextBox)itm.FindControl("XEndTime");
DropDownList ddlListView = (DropDownList)itm.FindControl("ddlListView");
XStartTime.Text = TimeVals[0].ToString().Trim();
XEndTime.Text = TimeVals[1].ToString().Trim();
try
{
newClass = typeof(PopupListSelect.Classrooms);
created = Activator.CreateInstance(newClass, Int32.Parse(HFBranchID.Value), ddlListView);
ddlListView.SelectedValue = HFBatchClRoom.Value;
}
catch
{
}
}
}
catch
{
}
}
protected void btnSave_Click(object sender, EventArgs e)
{
DataTable dt = new DataTable();
DataColumn dc;
DataRow dr;
dc = new DataColumn();
dc.DataType = System.Type.GetType("System.Int32");
dc.ColumnName = "BranchID";
dc.Unique = false;
dt.Columns.Add(dc);
dc = new DataColumn();
dc.DataType = System.Type.GetType("System.Int32");
dc.ColumnName = "CourseID";
dc.Unique = false;
dt.Columns.Add(dc);
dc = new DataColumn();
dc.DataType = System.Type.GetType("System.Int32");
dc.ColumnName = "BatchID";
dc.Unique = false;
dt.Columns.Add(dc);
dc = new DataColumn();
dc.DataType = System.Type.GetType("System.Int32");
dc.ColumnName = "CurriID";
dc.Unique = false;
dt.Columns.Add(dc);
dc = new DataColumn();
dc.DataType = System.Type.GetType("System.Int32");
dc.ColumnName = "TopicID";
dc.Unique = false;
dt.Columns.Add(dc);
dc = new DataColumn();
dc.DataType = System.Type.GetType("System.String");
dc.ColumnName = "TopicDate";
dc.Unique = false;
dt.Columns.Add(dc);
dc = new DataColumn();
dc.DataType = System.Type.GetType("System.String");
dc.ColumnName = "StartTime";
dc.Unique = false;
dt.Columns.Add(dc);
dc = new DataColumn();
dc.DataType = System.Type.GetType("System.String");
dc.ColumnName = "EndTime";
dc.Unique = false;
dt.Columns.Add(dc);
dc = new DataColumn();
dc.DataType = System.Type.GetType("System.Int32");
dc.ColumnName = "ClassroomID";
dc.Unique = false;
dt.Columns.Add(dc);
dc = new DataColumn();
dc.DataType = System.Type.GetType("System.String");
dc.ColumnName = "FacultyID";
dc.Unique = false;
dt.Columns.Add(dc);
foreach (RepeaterItem itm in rptTopics.Items)
{
TextBox XStartTime = (TextBox)itm.FindControl("XStartTime");
TextBox XEndTime = (TextBox)itm.FindControl("XEndTime");
DropDownList ddlListView = (DropDownList)itm.FindControl("ddlListView");
TextBox txtTopicDate = (TextBox)itm.FindControl("txtTopicDate");
Label lblID = (Label)itm.FindControl("lblID");
if (!txtTopicDate.Text.Equals(""))
{
dr = dt.NewRow();
dr["BranchID"] = Int32.Parse(HFBranchID.Value);
dr["CourseID"] = Int32.Parse(HFCourseID.Value);
dr["BatchID"] = Int32.Parse(HFBatchID.Value);
dr["CurriID"] = Int32.Parse(HFCurriculumID.Value);
dr["TopicID"] = Int32.Parse(lblID.Text);
dr["TopicDate"] = new Common.GeneralFunctions().ConvertDate_MM_DD_YY(txtTopicDate.Text.Trim());
dr["StartTime"] = XStartTime.Text;
dr["EndTime"] = XEndTime.Text;
dr["ClassroomID"] = Int32.Parse(ddlListView.SelectedValue);
dr["FacultyID"] = HFFacultyID.Value;
dt.Rows.Add(dr);
}
}
TopicScheduling.ScheduledTopics.XMLSaveTopicsToSchedule(dt);
Response.Redirect("~/Topic-Scheduling");
}
protected void btnGet_Click(object sender, EventArgs e)
{
getTopics();
//new BLL.Sch().Topics(Int32.Parse(HFBranchID.Value), Int32.Parse(HFCourseID.Value), Int32.Parse(HFBatchID.Value), Int32.Parse(HFCurriculumID.Value),HFFacultyID.Value,rptTopics);
Models.ScheduledTopics obj = new Models.ScheduledTopics();
obj.BranchID = Int32.Parse(HFBranchID.Value);
obj.CourseID = Int32.Parse(HFCourseID.Value);
obj.BatchID = Int32.Parse(HFBatchID.Value);
obj.CurriID = Int32.Parse(HFCurriculumID.Value);
List<Models.ScheduledTopics> objCollect = TopicScheduling.ScheduledTopics.ScheduledTopicsList(obj);
foreach (RepeaterItem itm in rptTopics.Items)
{
TextBox XStartTime = (TextBox)itm.FindControl("XStartTime");
TextBox XEndTime = (TextBox)itm.FindControl("XEndTime");
DropDownList ddlListView = (DropDownList)itm.FindControl("ddlListView");
TextBox txtTopicDate = (TextBox)itm.FindControl("txtTopicDate");
Label lblID = (Label)itm.FindControl("lblID");
for (int i = 0; i <= objCollect.Count - 1; i++)
{
if (objCollect[i].TopicID.ToString().Equals(lblID.Text))
{
XStartTime.Text = objCollect[i].StartTime;
XEndTime.Text = objCollect[i].EndTime;
txtTopicDate.Text = objCollect[i].TopicDate;
ddlListView.SelectedValue = objCollect[i].ClassroomID.ToString();
if (!HFFacultyID.Value.Equals(objCollect[i].FacultyID))
{
txtTopicDate.Enabled = false;
XStartTime.Enabled = false;
XEndTime.Enabled = false;
ddlListView.Enabled = false;
txtTopicDate.ForeColor = System.Drawing.Color.Red;
}
else
{
txtTopicDate.Enabled = true;
XStartTime.Enabled = true;
XEndTime.Enabled = true;
ddlListView.Enabled = true;
txtTopicDate.ForeColor = System.Drawing.Color.Green;
}
}
}
}
}
}
Yo mut ensure you have trust connection from your web server and your database server. i suggest you to ping database server from your web server,
For dignostic i suggest you also to read event log from your web server

combining between scripts

DriverId OrderCount OrderCountWhereNameIsNotNull
12 2 2
13 1 1
this is the current table which is being made by this code:
public partial class Control : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
OrderDataRepository rep = new OrderDataRepository();
var results = rep.GetAllOrderData().
GroupBy(o => o.DRIVER_ID).
Select(g =>
new
{
DriverId = g.Key,
OrderCount = g.Count(),
OrderCountWhereNameIsNotNull =
g.Count(o => o.RECEIVE_NAME != null)
}).ToList();
DataViewer.DataSource = results;
DataViewer.DataBind();
}
}
instead of the table I need to take and print for each DriverId a progress bar as in this script:
int OrderCount, OrderCountWhereNameIsNotNull;
System.Web.UI.WebControls.TableRow oRow;
System.Web.UI.WebControls.TableCell oCell;
System.Web.UI.HtmlControls.HtmlGenericControl oDiv;
while (true)
//loop through records
//do while not eof
{
oRow = new System.Web.UI.WebControls.TableRow();
oCell = new System.Web.UI.WebControls.TableCell();
oDiv = new System.Web.UI.HtmlControls.HtmlGenericControl("DIV");
OrderCount = 200; //get value from DB, convert to meaningful width
OrderCountWhereNameIsNotNull = 100; //get value from DB, convert to meaningful width
oDiv.InnerHtml = "<div style='border: 3px solid black; width: " + OrderCount + "px;'>";
oDiv.InnerHtml += Environment.NewLine + " <div style='border: 0px; background-color: red; width: " + OrderCountWhereNameIsNotNull + "px;'> </div>";
oDiv.InnerHtml += Environment.NewLine + "</div>";
oCell.Controls.Add(oDiv);
oRow.Cells.Add(oCell);
tblData.Rows.Add(oRow);
}
I cannot combine them, may be the script is not good...please help
at the moment my main page is:
<form id="Form1" runat="server">
<asp:GridView runat="server" ID="DataViewer">
</asp:GridView>
</form>
You will probably find it simpler to bind your grid to your dataset, rather than building a table that attempts to inject itself into a grid:
<asp:GridView ID="DataViewer" runat="server">
<Columns>
<TemplateColumn>
<ItemTemplate>
Put the code for rendering your progress bar here in pure HTML.
When you come to a value that will come from a row in your data, do like this:
<div style='width: <%# Eval("OrderCount") %>' />
</ItemTemplate>
</TemplateColumn>
</Columns>
</asp:GridView>

Categories

Resources