This is a migrated thread and some comments may be shown as answers.

Print Data Base Data ,When Click On Print Button Of rad Grid.

2 Answers 34 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Sairam
Top achievements
Rank 1
Sairam asked on 06 Jun 2013, 02:07 PM
Hello  Telerik  folks,can You help here
<telerik:RadGrid ID="RadGrid1" runat="server" OnNeedDataSource="RadGrid1_NeedDataSource"
            AutoGenerateColumns="false" onitemcommand="RadGrid1_ItemCommand">
            <MasterTableView AutoGenerateColumns="false">
                <Columns>
                    <telerik:GridTemplateColumn>
                        <ItemTemplate>
                            <asp:CheckBox ID="CheckBox1" runat="server"   />
                        </ItemTemplate>
                    </telerik:GridTemplateColumn>
                    <telerik:GridTemplateColumn UniqueName="employeenaem" HeaderText="EmployeeName">
                        <ItemTemplate>
                            <%#Eval("Employeename") %>
                        </ItemTemplate>
                    </telerik:GridTemplateColumn>
                    <telerik:GridTemplateColumn UniqueName="employeeDesgination" HeaderText="EmployeeDesignation">
                        <ItemTemplate>
                            <%#Eval("EmployeeDesignation")%>
                        </ItemTemplate>
                    </telerik:GridTemplateColumn>
                    <telerik:GridTemplateColumn UniqueName="Salary" HeaderText="salary">
                        <ItemTemplate>
                            <%#Eval("EmployeeSalary") %>
                        </ItemTemplate>
                    </telerik:GridTemplateColumn>
                </Columns>
            </MasterTableView>
        </telerik:RadGrid>
        <telerik:RadButton ID="RadButton1" runat="server" Text="Print"
        onclick="RadButton1_Click">
        </telerik:RadButton>

.aspx.cs
protected void RadButton1_Click(object sender, EventArgs e)
    {
        PrintDocument pd = new PrintDocument();
        foreach (GridDataItem item1 in RadGrid1.MasterTableView.Items)
        {  
            CheckBox ChkedList = (CheckBox)item1.FindControl("CheckBox1");
            if (ChkedList.Checked)
            {
                Index = item1.ItemIndex;
                DrawImage();
            }
           
        }
    }

 public void  DrawImage()
    {
        if (m_oConn.State != ConnectionState.Closed)
        {

            m_oConn.Open();
        }
        m_oCmd = new MySqlCommand("select * from  printtest",m_oConn);
        DataSet ds = new DataSet();
        m_aDp = new MySqlDataAdapter(m_oCmd);
        m_aDp.Fill(ds);
        string dempname,dempdesg;
        decimal dsalary;
        dempname=(string)ds.Tables[0].Rows[Index]["Employeename"];
        dempdesg=(string)ds.Tables[0].Rows[Index]["EmployeeDesignation"];
        dsalary=(decimal)ds.Tables[0].Rows[Index]["EmployeeSalary"];
        string drawString2 = string.Empty;
        Graphics g;
        Bitmap b;
        Page p;
        b = new Bitmap(790, 1050);
        g = Graphics.FromImage(b);
        p = this.Page;
        p.Response.ContentType = "image/jpeg";
        g.FillRectangle(new SolidBrush(Color.White), 0, 0, 790, 325);
        g.FillRectangle(new SolidBrush(Color.White), 0, 325, 790, 1050)
        FontFamily fm1 = new FontFamily("Consolas");
        Font drawFont = new Font(fm1, 12);
        Font drFont = new Font("Arial", 8);
        Font drFont1 = new Font("Arial", 9);
        Font drsmallFont = new Font("Arial", 8);
        Font drnarrowFont = new Font("Arial Narrow", 8);
      
        Font drnarrowFont1 = new Font("Verdana,sans-serif", 8);
        Font drarialblackFont = new Font("Arial Black", 10);

        SolidBrush drawBrush = new SolidBrush(Color.Black);

        PointF drawPoint = new PointF(140.0F, 290.0F);

        Pen pn = new Pen(drawBrush);
     
        string path = Server.MapPath("images/InfoImg.png");
        Bitmap logo = new Bitmap(path);

        Graphics gra = Graphics.FromImage(logo);
      
        g.DrawImage(logo, 15.0F, 30.0F);

        ImageConverter ic = new ImageConverter();

        g.DrawString("PAY TO THE ORDER OF ____" + "__________________________________________________________________", drnarrowFont1, drawBrush, 15.0F, 120.0F);
        g.DrawString(dempname + "is worked as " + dempdesg + "and erans" + dsalary, drnarrowFont1, drawBrush, 145.0F, 117.0F);
        b.Save(p.Response.OutputStream, ImageFormat.Jpeg);
        
    }

Here ...I want to print the .....Data That in database....not current document......based user select  Data-rows and then click on Print.. ...presently.  I want to print the Multiple Image files...based on user selected rows ..only one Image Show in page......I don't want to show printing information ..I want to Print ...Image files......I search many website...I am not getting results.....That why I am post the thread...

2 Answers, 1 is accepted

Sort by
0
Sairam
Top achievements
Rank 1
answered on 11 Jun 2013, 01:53 PM
Andrey,Thanks for your replay  ....if you say take another .....Radgrid2 in same page and  Display the .....Print page content in that ...after use your logic ....but ..can you provide  some simple ....sample to  this question it's very useful to..many folks like  me........
0
Andrey
Telerik team
answered on 12 Jun 2013, 07:43 AM
Hello,

The previous reply was mistakenly placed in your thread. It was aimed to help another user.

About your question I am afraid that this functionality is not available with our products and you need to implement it manually.

Regards,
Andrey
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
General Discussions
Asked by
Sairam
Top achievements
Rank 1
Answers by
Sairam
Top achievements
Rank 1
Andrey
Telerik team
Share this question
or