TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Baba Krishna
NA
18
6.9k
the print code is not work for two check boxes in itextsharp
Apr 23 2015 7:05 AM
can any body help me to find aa solution......it works only for only one grid.........thank u in advance
protected void Button6_Click1(object sender, EventArgs e)
{
for (int i = 1; i <= checkcatg.Items.Count; i++)
{
if (checkcatg.Items[0].Selected)
{
GridView1.Visible = true;
SqlConnection conn = new SqlConnection("server=.;database=project;uid=sa;pwd=abc;");
SqlCommand cmd = new SqlCommand("select * from pantsmeasurements where pant_id=(select MAX(pant_id) from pantsmeasurements)", conn);
DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
//printpants();
PdfPTable pdfTable = new PdfPTable(GridView1.HeaderRow.Cells.Count);
foreach (GridViewRow gridViewRow in GridView1.Rows)
{
foreach (TableCell tableCell in gridViewRow.Cells)
{
PdfPCell pdfcell = new PdfPCell(new Phrase(tableCell.Text));
pdfTable.AddCell(pdfcell);
}
}
Document pdfDocument = new Document(PageSize.A4, 10f, 10f, 10f, 10f);
PdfWriter.GetInstance(pdfDocument, Response.OutputStream);
pdfDocument.Open();
pdfDocument.Add(pdfTable);
pdfDocument.Close();
Response.ContentType = ("application/pdf");
Response.AppendHeader("content-dispostion", "attachment;filename=employees.pdf");
Response.Write(pdfDocument);
Response.Flush();
Response.End();
}
if (checkcatg.Items[1].Selected)
{
GridView2.Visible = true;
SqlConnection conn = new SqlConnection("server=.;database=project;uid=sa;pwd=abc;");
SqlCommand cmd = new SqlCommand("select * from shirtsmeasurements where shirt_id=(select MAX(shirt_id) from shirtsmeasurements)", conn);
DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(ds);
GridView2.DataSource = ds;
GridView2.DataBind();
//printshirts();
PdfPTable pdfTable = new PdfPTable(GridView2.HeaderRow.Cells.Count);
foreach (GridViewRow gridViewRow in GridView2.Rows)
{
foreach (TableCell tableCell in gridViewRow.Cells)
{
PdfPCell pdfcell = new PdfPCell(new Phrase(tableCell.Text));
pdfTable.AddCell(pdfcell);
}
}
Document pdfDocument = new Document(PageSize.A4, 10f, 10f, 10f, 10f);
PdfWriter.GetInstance(pdfDocument, Response.OutputStream);
pdfDocument.Open();
pdfDocument.Add(pdfTable);
pdfDocument.Close();
Response.ContentType = ("application/pdf");
Response.AppendHeader("content-dispostion", "attachment;filename=employees.pdf");
Response.Write(pdfDocument);
Response.Flush();
Response.End();
}
Reply
Answers (
1
)
How to hide Sub report in Crystal report
technology used in a website