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
1775
Exporting TemplateDataField in pdf
posted

Normal 0 false false false MicrosoftInternetExplorer4

Hello!

How to export colums with type TemplateDataField  in pdf file by WebDocumentExporter?

 

<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">


    <title></title>

</head>

<body>

    <form id="form1" runat="server">

    <div>   

        <ig:WebDataGrid ID="WebDataGrid1" runat="server" AutoGenerateColumns="False"

            Height="350px" Width="400px">

            <Columns>

                <ig:BoundDataField DataFieldName="index" Key="index">

                    <Header Text="index" />

                </ig:BoundDataField>

                <ig:BoundDataField DataFieldName="name" Key="name">

                    <Header Text="name" />

                </ig:BoundDataField>

                <ig:TemplateDataField Key="sex">

                    <Header Text="sex" />

                     <ItemTemplate>

                                <div style="text-align: center;"><asp:CheckBox runat="server" ID="key_" Checked='<%# DataBinder.Eval(Container, "DataItem.sex")%>'/></div>

                            </ItemTemplate>

                </ig:TemplateDataField>

            </Columns>

        </ig:WebDataGrid>

        <igtxt:WebImageButton ID="WebImageButton1" runat="server"

            onclick="WebImageButton1_Click" Text="pdf">

        </igtxt:WebImageButton>

        <ig:WebScriptManager ID="WebScriptManager1" runat="server">

        </ig:WebScriptManager>   

    </div>

    <ig:WebDocumentExporter ID="WebDocumentExporter1" runat="server"

        DownloadName="Mypdf.pdf">

    </ig:WebDocumentExporter>

    </form>

</body>

</html>



 cs file:

 

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Data;

 

namespace WebApplication1

{

    public partial class MyPage : System.Web.UI.Page

    {

        protected void Page_Load(object sender, EventArgs e)

        {

            DataTable dt = new DataTable("MyTable");

            dt.Columns.Add("index", typeof(int));

            dt.Columns.Add("name", typeof(string));

            dt.Columns.Add("sex", typeof(bool));

 

            dt.Rows.Add(new object[] { 1, "Tom", true });

            dt.Rows.Add(new object[] { 2, "Ben", true });

            dt.Rows.Add(new object[] { 3, "Mary", false });

            dt.Rows.Add(new object[] { 4, "Kat", false });

            WebDataGrid1.DataSource = dt;

        }

        protected void WebImageButton1_Click(object sender, Infragistics.WebUI.WebDataInput.ButtonEventArgs e)

        {

            WebDocumentExporter1.Export(WebDataGrid1);

        }

    }

}  

result:


 

Thank you for help me!