|
SayamiSuchi wrote: i got these problems when i try to join multiple tables
Then how can it not be the database? How are you joining the tables? Are you using an INNER JOIN or an OUTER JOIN? No matter, you can still filter out the empty rows before binding to the repeater.
No comment
|
|
|
|
|
no i am just using nested repeaters
suchita
|
|
|
|
|
OK, lets start from the beginning. Where is the data coming from? What nested repeaters? You have only shown one.
No comment
|
|
|
|
|
Ok. I have database something like this: For pdf I have used iTextSharp 4.2.1.0 version. pdf part is working fine but pdf page break is where I got problem.
table one is
CustomerOrder
--------------
FirstName
LastName
GroupName
Email
CreationDate
second table is
OrderItem
------------
ID
OrderID
Item
ItemDescription
Category
Amount
CustomerID
IsActive
Now my design page is like this:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="MainPage.aspx.cs" Inherits="iTextSharpExample._Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<asp:Button ID="pdfReportFromDatabase" runat="server" onclick="pdfReportFromDatabase_Click" Text="Button" />
<div>
</div>
<asp:Repeater runat="server" ID="cusDptInfo" onitemdatabound="cusDptInfo_ItemDataBound" >
<ItemTemplate ><font size="60%">
<%# DataBinder.Eval(Container.DataItem, "FirstName") %> <%# DataBinder.Eval(Container.DataItem, "LastName") %><br />
<%# DataBinder.Eval(Container.DataItem, "GroupName") %><br />
<%# DataBinder.Eval(Container.DataItem, "Email") %><br />
<%# DataBinder.Eval(Container.DataItem, "CreationDate","{0:MM/dd/yyyy}") %><br />
<br /></font>
<asp:Repeater ID="rptItemList" runat="server">
<ItemTemplate>
<asp:Table ID="tblItemList" runat="server" Font-Size="7%">
<asp:TableRow>
<asp:TableCell><%# DataBinder.Eval(Container.DataItem,"Item")%> <%#DataBinder.Eval(Container.DataItem, "Category","({0})")%><br /><font color="gray" style="text-align:justify"><%# DataBinder.Eval(Container.DataItem, "ItemDescription") %></font></asp:TableCell>
<asp:TableCell HorizontalAlign="Right"><%# DataBinder.Eval(Container.DataItem,"Amount","{0:c}") %></asp:TableCell>
</asp:TableRow>
</asp:Table>
</ItemTemplate>
</asp:Repeater>
<asp:Repeater ID="rptOrderedTotAmount" runat="server">
<ItemTemplate> <div style="page-break-after:always;">
<asp:Table ID="tblItemListt" runat="server" Font-Size="7%">
<asp:TableRow>
<asp:TableCell HorizontalAlign="Right"><%# DataBinder.Eval(Container.DataItem, "TotalAmount","Total: {0:c}") %></asp:TableCell>
</asp:TableRow>
</asp:Table> </div>
<br />
</ItemTemplate>
</asp:Repeater>
</ItemTemplate>
</asp:Repeater>
</form>
</body>
</html>
and my code behind is like this:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.OleDb;
using System.IO;
using iTextSharp.text;
using iTextSharp.text.pdf;
using iTextSharp.text.html;
using iTextSharp.text.html.simpleparser;
namespace iTextSharpExample
{
public partial class _Default : System.Web.UI.Page
{
public static string strCnx = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=g:\\access\\CustomerOrderDetails.mdb;Jet OLEDB:System Database=g:\\access\\system.mdw;"
;
#region Properties
Repeater rptItemList;
Repeater rptOrderedTotAmount;
#endregion
protected void Page_Load(object sender, EventArgs e)
{
}
protected void filetesting()
{
OleDbConnection cnx = new OleDbConnection(strCnx);
DataSet ds = new DataSet();
string catQuery = @"select * from CustomerOrder";
OleDbCommand objCmd = new OleDbCommand(catQuery, cnx);
OleDbDataAdapter objDAcategory = new OleDbDataAdapter(objCmd);
objDAcategory.Fill(ds, "CustomerOrder");
string totQuery = @"select OrderID,sum(Amount) As [TotalAmount] from OrderedItem where IsActive = '1' group by OrderID";
objCmd = new OleDbCommand(totQuery, cnx);
OleDbDataAdapter objDAtotal = new OleDbDataAdapter(objCmd);
objDAtotal.Fill(ds, "OrderedItem");
string itemQuery = @"select * from OrderedItem where IsActive='1'";
objCmd = new OleDbCommand(itemQuery, cnx);
OleDbDataAdapter objDAitem = new OleDbDataAdapter(objCmd);
objDAitem.Fill(ds, "OrderedItem");
DataRelation dRel = new DataRelation("CustomerOrder_OrderedItem", ds.Tables["CustomerOrder"].Columns["OrderID"], ds.Tables["OrderedItem"].Columns["OrderID"]);
ds.Relations.Add(dRel);
cusDptInfo.DataSource = ds;
cusDptInfo.DataBind();
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=iTextSharpExample.pdf");
HttpContext.Current.Response.Charset = "";
HttpContext.Current.Response.ContentType = "application/pdf";
StringWriter stringwrite = new StringWriter();
HtmlTextWriter htmlwrite = new HtmlTextWriter(stringwrite);
cusDptInfo.RenderControl(htmlwrite);
StringReader sr = new StringReader(stringwrite.ToString());
Document pdfDoc = new Document(PageSize.A4, 50f, 50f, 40f, 40f);
PdfWriter writer = PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
string pcnt;
pcnt = (writer.CurrentPageNumber - 1).ToString();
pcnt = pcnt.Substring(1);
HeaderFooter header = new HeaderFooter(new Phrase("My Company \n Customer Order Details"), false) { Border = Rectangle.NO_BORDER, Alignment = Element.ALIGN_CENTER };
HeaderFooter footer = new HeaderFooter(new Phrase(pcnt), true) { Border = Rectangle.NO_BORDER, Alignment = Element.ALIGN_CENTER };
pdfDoc.Header = header;
pdfDoc.Footer = footer;
pdfDoc.Open();
_events e = new _events();
e.TimerText = DateTime.Now.ToString("MM/dd/yyyy");
writer.PageEvent = e;
htmlparser.Parse(sr);
pdfDoc.NewPage();
pdfDoc.Close();
Response.Write(pdfDoc);
}
protected void cusDptInfo_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
RepeaterItem item = e.Item;
if ((item.ItemType == ListItemType.Item) ||
(item.ItemType == ListItemType.AlternatingItem))
{
rptItemList = (Repeater)e.Item.FindControl("rptItemList");
DataRowView drv = (DataRowView)item.DataItem;
rptItemList.DataSource = drv.CreateChildView("CustomerOrder_OrderedItem");
rptItemList.DataBind();
rptOrderedTotAmount = (Repeater)e.Item.FindControl("rptOrderedTotAmount");
DataRowView drvTot = (DataRowView)item.DataItem;
rptOrderedTotAmount.DataSource = drvTot.CreateChildView("CustomerOrder_OrderedItem");
rptOrderedTotAmount.DataBind();
}
}
protected void pdfReportFromDatabase_Click(object sender, EventArgs e)
{
filetesting();
}
}
public class _events : PdfPageEventHelper
{
private string _timerText;
public string TimerText
{
get { return _timerText; }
set { _timerText = value; }
}
public override void OnEndPage(PdfWriter writer, Document document)
{
base.OnEndPage(writer, document);
Rectangle page = document.PageSize;
ColumnText.ShowTextAligned(writer.DirectContent, Element.ALIGN_RIGHT, new Phrase(TimerText), page.Right, page.Height - document.TopMargin, 0);
}
}
}
ok I need to page break once i get my TotalAmount. I had used style=page-break-after:always property under the nested repeater as shown. Its working for part of data and for part of data, its not working. Page break is happening for some part and for some part there is no page break. This is my problem. I need page break throughout my data.
suchita
|
|
|
|
|
This isn't even close to what originally asked. First you wanted to remove empty cells now you want page breaks in a PDF?
No comment
|
|
|
|
|
Sorry also when i am showing the total amount, based on the second repeaters items number, the correspoding empty lines been added after the total amount. I need to delete those empty cells too.
suchita
|
|
|
|
|
anyone any ideas yet? I'm still having the problem.
suchita
|
|
|
|
|
I want a one book about ASP and code ASP. thanks
|
|
|
|
|
I want a million dollars and the letter M stricken from the English language. Who is going to get their wish first?
I know the language. I've read a book. - _Madmatt
"The OP herself was not sure about her question"
"The OP is from India and I know what she meant."
|
|
|
|
|
Mark Nischalke wrote: and the letter M stricken from the English language
I'm just being curious, but what's so great about having Ark as a first name?
A still living curious cat!
"With sufficient thrust, pigs fly just fine."
Ross Callon, The Twelve Networking Truths, RFC1925
|
|
|
|
|
Old joke from Steve Martin, or Steve Artin.
"I have some hostages, and they are tied up in a sack at the top of a flag pole. I'm going to blow them up at midnight, unless I get these three demands: ONE! I want a million dollars! TWO: I want a getaway car waiting for me! and THREE: I want the letter M stricken from the English language. See, you have to make one crazy demand, so if they catch you, you can plead insanity. Heh, heh, getaway car."
I know the language. I've read a book. - _Madmatt
"The OP herself was not sure about her question"
"The OP is from India and I know what she meant."
|
|
|
|
|
Mark Nischalke wrote: See, you have to make one crazy demand, so if they catch you, you can plead
insanity. Heh, heh, getaway car."
Common sense is admitting there is cause and effect and that you can exert some control over what you understand.
|
|
|
|
|
OP seems not amused at all. Countered! 5+
"With sufficient thrust, pigs fly just fine."
Ross Callon, The Twelve Networking Truths, RFC1925
|
|
|
|
|
Thank Manfred...
Common sense is admitting there is cause and effect and that you can exert some control over what you understand.
|
|
|
|
|
Univote countered
OP was not amused!
"With sufficient thrust, pigs fly just fine."
Ross Callon, The Twelve Networking Truths, RFC1925
|
|
|
|
|
Manfred R. Bihy wrote: OP was not amused!
Or just doesn't like Steve Martin. He is rather old and outdated now.
No comment
|
|
|
|
|
So if I understood your explanation further down the thread correctly you missed an important addition:
Mark Nischalke wrote: I want a million dollars and the letter M stricken from the English language. Heh heh, one million dollars.
"With sufficient thrust, pigs fly just fine."
Ross Callon, The Twelve Networking Truths, RFC1925
|
|
|
|
|
Getting a million dollars is easy. Create a .99 iPhone App, there are at least 2 million (Steve Jobs needs his cut) stupid iPhone users who will buy it.
No comment
|
|
|
|
|
Hi,
I have a web form that allows users to upload files while opening a ticket in our system.
The upload is done using the "ajax control toolkit" asyncFileUpload.
Currently, the files are saved to a temp directory and will only be save to the permanent location when the user hits the "commit" button.
I would like to be able to get rid of temp files that are no longer relevant (e.g. The user leaves the page open for a month without posting the form).
What would be the best way to not keep temp files forever.
Maybe keeping them files in the session?
Maybe keeping them in the viewstate?
I could add some JS to the page with a timeout and add some code that runs when the user leaves the page. But these ideas are client side solutions. I wouldn't want someone to tamper with the code and leave me rubbish on my system.
Any other idea?
Thanks,
Summerbulb
|
|
|
|
|
Service/scheduled task on the server that will delete files older than X?
|
|
|
|
|
How about placing the cleanup code in the same area as where the user is allowed to upload his files temporarily.
Something like:
1) User wants to upload file.
2) check for any files that are older than "X" days and delete them
3) Continue with the upload logic
This eliminates the need for creating a separate task that would run as a service or scheduled task.
Just a thought.
|
|
|
|
|
Hi ,
I have an application that will collect data from user (entering time sheet data)
so the status of Time sheet can be any of the following
1. Open
2. Saved
3. submited
4. Under Review
5. Approvred.
6. Reject
I am displaying a report on this data. Consider a case where user daily saving his time sheet but not submitting.
My report will be like below
Userid Date Status.
111 Date1 Open
111 Date1 Saved
111 Date1 Saved
111 Date2 Saved
111 Date3 Saved
111 Date4 Submitted
111 Date5 Under Review
111 Date6 Under Review
111 Date7 Under Review
111 Date7 Reject
111 Date7 Saved
111 Date7 Saved
111 Date7 submit
:
:
Above are actual events done on the user time sheet . It looks like that duplicate data saved but it is displaying all the events.
My requirement is to delete duplicate records if the current and previous records are having the same status .
I can do his by looping through all the records using "for" by cecking previous and curent satus.
But i want this is to be done in diffrent way, Can anyone suggest if we can use LINQ for this, if so please suggest me.
Thanks,
|
|
|
|
|
You don't need LINQ to do this, and it would really be unsuitable for the task. Plain SQL should do the trick. This[^] article might help.
"Don't confuse experts with facts" - Eric_V
|
|
|
|
|
So you want an explaination as to why this was marked as a bad answer?
The OP asked
salmonraju wrote: Can anyone suggest if we can use LINQ for this
and you reponded
Shameel wrote: You don't need LINQ to do this
The question wasn't whether or not they needed LINQ for this is was IF it were possible to use LINQ. A bad answer since it did not answer the question that was posed.
Shameel wrote: Plain SQL should do the trick.
The OP made no mention of how the data was being stored. Perhaps it was an in-memory datastore, an XML file, a flat file, etc. A bad answer since it made an unjustified assumption rather than ask for clarification.
Now you have your explanation. You will no doubt disagree, that's you up to you.
Now, leave it alone, go way, grow a thicker skin. Everyone else does not need to be subjected to your paranoia and sense of being pursecuted.
I know the language. I've read a book. - _Madmatt
"The OP herself was not sure about her question"
"The OP is from India and I know what she meant." - Shameel
modified on Tuesday, August 23, 2011 9:10 AM
|
|
|
|
|
Mark Nischalke wrote: The question wasn't whether or not they needed LINQ for this is was IF it were possible to use LINQ.
IMO, a good professional is one who provides the best way to complete a task, not just what the OP asks for, and that is what I did. If there is problem with it, let the OP speak out, there's no need for you to keep pestering everyone here.
Mark Nischalke wrote:
The OP made no mention of how the data was being stored. Perhaps it was an in-memory datastore, an XML file, a flat file, etc. A bad answer since it made an unjustified assumption rather than ask for clarification. To light up your short lived memory, you have a problem with asking for clarification too. Here's an example[^].
So it doesn't matter what I do, you need a reason to downvote me and you see an opportunity to do it in everything I post. I have no problem with it if that gives you satisfaction. Only a minion would do it and you never fail to prove that you are one.
Mark Nischalke wrote: Now, leave it alone, go way, grow a thicker skin. Everyone else does not need to be subjected to your paranoia and sense of being pursecuted.
I did not litter your posts, it's the other way round, you came here uninvited and probably you should go away.
"Don't confuse experts with facts" - Eric_V
|
|
|
|
|