Click here to Skip to main content
13,197,117 members (60,605 online)
Rate this:
 
Please Sign up or sign in to vote.
See more:
Hello Friends,

I have another problem for export data which is bind in grid view.

I have many column in grid view ans some Bound Field is visible= false.

When I want to export data in Excel I also want to export BouldField value which is hide.

Here is my gridview.
<asp:GridView ID="GrdOrder" runat="server" AutoGenerateColumns="false"
                            AllowPaging="true" AllowSorting="true" PageSize="20"
                            DataKeyNames="OrderID" CssClass="Grid"
                            onpageindexchanging="GrdOrder_PageIndexChanging"
                            onselectedindexchanged="GrdOrder_SelectedIndexChanged">
                        <Columns>
                            <asp:TemplateField>
                                <HeaderTemplate>
                                    <input type="checkbox" name="SelectAllCheckBox" onclick="SelectAll(this)" />
                                </HeaderTemplate>
                                <ItemTemplate>
                                    <asp:CheckBox ID="ChkOrderId" runat="server" />
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:BoundField HeaderText="Order No" DataField="OrderID" />
                            <asp:BoundField HeaderText="Order Date" DataField="OrderDate" DataFormatString="{0:dd-MMM-yyyy}" />
                            <asp:BoundField HeaderText="Customer Name" DataField="ShippingCustomerName" />
                            <asp:BoundField HeaderText="Order Status" DataField="OrderStatus" />
                            <asp:BoundField HeaderText="Bill Address" DataField="BillngAddress" />
                            <asp:CommandField ShowSelectButton="true" ButtonType="Image" SelectImageUrl="images/details.png" HeaderText="More Details"/>
                        </Columns>
                        <FooterStyle />
                        <SelectedRowStyle />
                        <PagerStyle CssClass="GridPager" />
                        <HeaderStyle CssClass="HeaderProduct" />
                    </asp:GridView>


Hhere is some code for export that hide field.
GrdOrder.HeaderRow.Cells[0].Visible = false;
        GrdOrder.HeaderRow.Cells[5].Visible = true;
 
        //Temp Code
        for (int i = 0; i < GrdOrder.Rows.Count; i++)
        {
            GridViewRow rw = GrdOrder.Rows[i];
            rw.Visible = true;
            GrdOrder.Columns[5].Visible = true;
            rw.Cells[0].Visible = false;
            rw.Cells[5].Visible = true;
        }
 
        for (int i = 0; i < GrdOrder.HeaderRow.Cells.Count; i++)
        {
            //GrdOrder.HeaderRow.Cells[i].Style.Add("background-color", "#E4E4E4");
            //GrdOrder.HeaderRow.Cells[i].Style.Add("color", "#444");
            GrdOrder.HeaderRow.Cells[i].Style.Add("font-size", "12pt");
            GrdOrder.HeaderRow.Cells[i].Style.Add("text-decoration", "bold");
            GrdOrder.Style.Add("font-family", "Verdana;");
            GrdOrder.Style.Add("font-size", "12pt");
            //GrdOrder.Style.Add("color", "Black");
        }

Can help me for that. !!!
Posted 3-Oct-12 4:30am
Updated 3-Oct-12 18:00pm
v3
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

I would recommend to use Sql Reporting services to export to excel / print functionality. You can choose client reporting which is rdlc which would be more suitable for you as you have data on client side.

Thanks
Rohit
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 3

  Permalink  

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy |
Web04 | 2.8.171020.1 | Last Updated 4 Oct 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100