Click here to Skip to main content
15,885,067 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have create a report on label and i want export it in pdf on button click what's the code for that???

Plz help me ...

Thanks...
Posted
Comments
OriginalGriff 9-Sep-14 4:59am    
What have you tried?
Where are you stuck?
We are not a "code writing" service.

 
Share this answer
 
i have code on click button like this...

XML
con = clsSql.getconnection;
        try
        {

            lblExcept.Text = null;

            if (Convert.ToInt32(con.State) < 1)
            {
                con.Open();
            }
            frmDt = txtFromDate.Text.Trim();
            endDt = txtEndDate.Text.Trim();
            dd = frmDt.Substring(0, 2);
            mm = frmDt.Substring(3, 2);
            yy = frmDt.Substring(6, 4);
            frmDt = mm + "/" + dd + "/" + yy;

            dd = endDt.Substring(0, 2);
            mm = endDt.Substring(3, 2);
            yy = endDt.Substring(6, 4);
            endDt = mm + "/" + dd + "/" + yy;
            lblExcept.Text = null;
            lblTab.Text = null;



            query = @"select did,Sno,convert(varchar(11),Date,106) as Date,REGION,CLIENTSNAME,ShortAddress,CATEGORY,
Local_Corporate_Client,PERSON,MOB_PH_No,EMAIL,AGENCY,HOTCLINT,
TARGET,Visitby,Remarks from DSR where Date between '" + frmDt + @"' and '" + endDt + "' ";

            cmd = new SqlCommand(query, con);
            dr = cmd.ExecuteReader();
            lblTab.Text = null;
            if (dr.HasRows)
            {

                lblTab.Text += @"<table id='data-grid'  class='alternate' border='0' cellpadding='0' cellspacing='0'>";

                lblTab.Text += @"<tr>";

                lblTab.Text += @"<th width='50' align='left'>SlNo</th>";
                lblTab.Text += @"<th width='110' align='left'>Date</th>";
                lblTab.Text += @"<th width='110' align='left'>REGION</th>";
                lblTab.Text += @"<th width='110' align='left'>CLIENTSNAME</th>";
                lblTab.Text += @"<th width='110' align='left'>ShortAddress</th>";
                lblTab.Text += @"<th width='110' align='left'>CATEGORY</th>";
                lblTab.Text += @"<th width='110' align='left'>Local_Corporate_Client</th>";
                lblTab.Text += @"<th width='110' align='left'>PERSON</th>";
                lblTab.Text += @"<th width='50' align='left'>MOB_PH_No</th>";
                lblTab.Text += @"<th width='50' align='left'>EMAIL</th>";
                lblTab.Text += @"<th width='50' align='left'>AGENCY</th>";
                lblTab.Text += @"<th width='50' align='left'>HOTCLINT</th>";
                lblTab.Text += @"<th width='50' align='left'>TARGET</th>";
                lblTab.Text += @"<th width='50' align='left'>Visitby</th>";
                lblTab.Text += @"<th width='50' align='left'>Remarks</th>";

                lblTab.Text += @"</tr>";

                NetAmt = 0;

                while (dr.Read())
                {
                    i += 1;


                    lblTab.Text += @"<tr>";
                    lblTab.Text += @"<td valign='top'>" + i + "</td>";

                    lblTab.Text += @"<td valign='top'>" + Convert.ToString(dr["Date"]) + "</td>";
                    lblTab.Text += @"<td valign='top'>" + Convert.ToString(dr["REGION"]) + "</td>";
                    lblTab.Text += @"<td valign='top'>" + Convert.ToString(dr["CLIENTSNAME"]) + "</td>";
                    lblTab.Text += @"<td valign='top'>" + Convert.ToString(dr["ShortAddress"]) + "</td>";
                    lblTab.Text += @"<td valign='top'>" + Convert.ToString(dr["CATEGORY"]) + "</td>";
                    lblTab.Text += @"<td valign='top'>" + Convert.ToString(dr["Local_Corporate_Client"]) + "</td>";
                    lblTab.Text += @"<td valign='top'>" + Convert.ToString(dr["PERSON"]) + "</td>";
                    lblTab.Text += @"<td valign='top'>" + Convert.ToString(dr["MOB_PH_No"]) + "</td>";
                    lblTab.Text += @"<td valign='top'>" + Convert.ToString(dr["EMAIL"]) + "</td>";
                    lblTab.Text += @"<td valign='top'>" + Convert.ToString(dr["AGENCY"]) + "</td>";
                    lblTab.Text += @"<td valign='top'>" + Convert.ToString(dr["HOTCLINT"]) + "</td>";
                    lblTab.Text += @"<td valign='top'>" + Convert.ToString(dr["TARGET"]) + "</td>";
                    lblTab.Text += @"<td valign='top'>" + Convert.ToString(dr["Visitby"]) + "</td>";
                    lblTab.Text += @"<td valign='top'>" + Convert.ToString(dr["Remarks"]) + "</td>";

                    lblTab.Text += @"</tr>";

                }

                lblTab.Text += @"</table>";

            }
            else
            {
                lblTab.Text = "Data Not Found Please Check Date...";
            }

            if (dr.IsClosed == false)
            {
                dr.Close();
            }


        }
        catch (Exception ex)
        {
            lblExcept.Text = ex.Message.ToString();

        }
        finally
        {
            if (Convert.ToInt32(con.State) >= 1)
            {
                con.Close();
            }
        }




i want export result in pdf...
 
Share this answer
 
Comments
Magic Wonder 9-Sep-14 5:18am    
if you are sharing your code w.r.t. your question, kindly add it with question with the help of Improve Question and delete the same from solution.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900