Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
710
How to export textbox value to pdf doc using Infragistics 2011.1
posted

Hi

In this new version 2011.1 of Infragistic I have been unsuccessfull in exporting a text box to pdf doc. In the earlier version I had success in exporting text box please see code in code behind page below that is commented out. Anyway this code will not work in the new version. So when i export to pdf it only displays the webgrid and its content fine but not the textbox data. Can anyone suggest a solution

SOURCE CODE
 
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="displayRosterScheduledEvents.aspx.cs" Inherits="FPR.Reports.displayRosterScheduledEvents" %>
 
<%@ Register assembly="Infragistics35.Web.v11.1, Version=11.1.20111.2036, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb" namespace="Infragistics.Web.UI.GridControls" tagprefix="ig" %>
<%@ Register assembly="Infragistics35.Web.v11.1, Version=11.1.20111.2036, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb" namespace="Infragistics.Web.UI" tagprefix="ig" %>
 
<!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>
        <link rel="stylesheet" type="text/css" href="../Main.css" />
    <style type="text/css">
        .style1
        {
            width: 750px;
        }
        .style2
        {
            width: 625px;
        }
        .style3
        {
            width: 625px;
            text-align: center;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
   
        <table class="style1">
            <tr>
                <td class="style2">
                    &nbsp;</td>
                <td>
                    &nbsp;</td>
            </tr>
            <tr>
                <td class="style3">
                    <asp:Label ID="Label1" runat="server"
                        style="font-size: medium; font-weight: 700" Text="Roster for Scheduled Event"></asp:Label>
                </td>
                <td>
                    &nbsp;</td>
            </tr>
            <tr>
                <td class="style2">
                    &nbsp;</td>
                <td>
                    &nbsp;</td>
            </tr>
            <tr>
                <td class="style2">
                    <br />
                    &nbsp;<asp:TextBox ID="TextBox1" runat="server" style="text-align: center; font-size: medium"
                        Width="610px"></asp:TextBox>
                    <br />
                    &nbsp;<asp:TextBox ID="TextBox2" runat="server"
                        style="text-align: center; font-size: medium" Width="610px"></asp:TextBox>
                    <br />
&nbsp;<asp:TextBox ID="TextBox3" runat="server" style="text-align: center; font-size: medium"
                        Width="610px"></asp:TextBox>
                    <br />
                    &nbsp;<asp:TextBox ID="TextBox4" runat="server" style="text-align: center; font-size: medium" Width="610px"></asp:TextBox>
                    <br />
                </td>
                <td>
                    &nbsp;</td>
            </tr>
            <tr>
                <td class="style2">
                    &nbsp;</td>
                <td>
                    &nbsp;</td>
            </tr>
            <tr>
                <td class="style2">
                    <asp:LinkButton ID="btnExport" runat="server" onclick="btnExport_Click">Export
                    To PDF</asp:LinkButton>
                </td>
                <td>
                    &nbsp;</td>
            </tr>
            <tr>
                <td class="style2">
                    &nbsp;</td>
                <td>
                    &nbsp;</td>
            </tr>
            <tr>
                <td class="style2">
                    <ig:WebDataGrid ID="WebDataGrid1" runat="server" AutoGenerateColumns="False"
                        DataSourceID="SqlDataSource1" Height="250px" Width="614px">
                        <Columns>
                            <ig:BoundDataField DataFieldName="PK_scheduledEventID" Hidden="True"
                                Key="PK_scheduledEventID">
                                <Header Text="PK_scheduledEventID" />
                            </ig:BoundDataField>
                            <ig:BoundDataField DataFieldName="Client" Key="Client">
                                <Header Text="Client" />
                            </ig:BoundDataField>
                            <ig:BoundDataField DataFieldName="Phone" Key="Phone">
                                <Header Text="Phone" />
                            </ig:BoundDataField>
                            <ig:UnboundField Key="UnboundField_0">
                                <Header Text="Signature" />
                            </ig:UnboundField>
                        </Columns>
                    </ig:WebDataGrid>
                   
                </td>
                <td>
                    &nbsp;</td>
            </tr>
        </table>
   
    </div>
    <ig:WebScriptManager ID="WebScriptManager1" runat="server">
    </ig:WebScriptManager>
    <asp:Button ID="Button1" runat="server" onclick="Button1_Click"
        Text="Go Back" />
                   
                    <asp:SqlDataSource ID="SqlDataSource1" runat="server"
                        ConnectionString="<%$ ConnectionStrings:fcrrConn %>"
                       
        SelectCommand="SELECT * FROM [getRosterScheduledEvents] WHERE ([PK_scheduledEventID] = @PK_scheduledEventID)">
                        <SelectParameters>
                            <asp:QueryStringParameter Name="PK_scheduledEventID"
                                QueryStringField="PK_scheduledEventID" Type="Int32" />
                        </SelectParameters>
                    </asp:SqlDataSource>
    <ig:WebDocumentExporter ID="WebDocumentExporter1" runat="server"
        DataExportMode="AllDataInDataSource" DownloadName="Report">
    </ig:WebDocumentExporter>
    </form>
<p>
    &nbsp;</p>
</body>
</html>
 
__________________________________________________________________________________________________________________________________
CODE BEHIND
 
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.SqlClient;
using Infragistics.Web.UI.GridControls;
using Infragistics.Documents.Reports.PDF;
 
 
 
namespace FPR.Reports
{
    public partial class displayRosterScheduledEvents : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string connStr = "Data Source=hsa-quin;Initial Catalog=fcrr;Persist Security Info=True;User ID=joaquin;Password=btdsqlhsa";
            string sql;
 
            sql = "SELECT PK_scheduledEventID, Event, Convert(varchar(10), scheduledEventStartDate,110) as scheduledEventStartDate, locLocationName, (locStreetAddress)+', '+(locCity)AS locAddress FROM getFutureScheduledEvents WHERE PK_scheduledEventID = " + System.Convert.ToInt32(Request.QueryString["PK_scheduledEventID"]).ToString();
 
            SqlDataAdapter adapter;
            adapter = new SqlDataAdapter(sql, connStr);
            DataSet ds = new DataSet();
            adapter.Fill(ds);
            DataTable myTable;
            myTable = ds.Tables[0];
            DataRow myRow = ds.Tables[0].Rows[0];
 
            TextBox1.Text = ds.Tables[0].Rows[0]["Event"].ToString();
            TextBox2.Text = ds.Tables[0].Rows[0]["scheduledEventStartDate"].ToString();
            TextBox3.Text = ds.Tables[0].Rows[0]["locLocationName"].ToString();
            TextBox4.Text = ds.Tables[0].Rows[0]["locAddress"].ToString();
        }
 
        protected void btnExport_Click(object sender, EventArgs e)
        {
            WebDocumentExporter1.Export(WebDataGrid1);
        }
 
        protected void Button1_Click(object sender, EventArgs e)
        {
            Response.Redirect("displayFutureScheduledEvents.aspx");
        }
 
        protected void LinkButton1_Click(object sender, EventArgs e)
        {
            WebDocumentExporter1.Export(WebDataGrid1);
        }
 

       
    }
/*
        protected void WebDocumentExporter1_Exporting(object sender, Infragistics.Web.UI.GridControls.DocumentExportingEventArgs e)
       {
           
                   // Add a title to the report
                   ReportText.IText heading = e.Section.AddText();
                   ReportText.Style headingStyle = new ReportText.Style(new Font("Tahoma", 14), Brushes.Crimson);
                   
           
                   heading.AddContent("Duration of Event was " + Session["myEvent"], headingStyle);
                   heading.AddContent("Class Roster for " + Session["myLocation"] + " on " + Session["myDate"], headingStyle);
                   heading.Margins.Bottom = 15;
 
                   ReportText.IText caption = e.Section.AddText();
                   ReportText.Style captionStyle = new ReportText.Style(new Font("Tahoma", 10), Brushes.Black);
                   caption.AddContent("The Name of this Event is " + Session["myEvent"], captionStyle);
                   caption.Margins.Bottom = 15;
 

                   // Add a caption with some more information
                   ReportText.IText caption1 = e.Section.AddText();
                   ReportText.Style captionStyle1 = new ReportText.Style(new Font("Tahoma", 10), Brushes.Black);
                   caption.AddContent("Duration of Event was " + Session["myEvent"], captionStyle);
                   caption1.Margins.Bottom = 15;
*/
}