Click here to Skip to main content
11,477,625 members (74,612 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET
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 5:30am
Edited 3-Oct-12 19: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  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

hello
i will prefer you following link
just study it
and if you think this will help you
then use it

Export to excel[^]

may be help you
Thank You
Chetan V.
  Permalink  

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 239
1 Richard Deeming 225
2 Tomas Takac 150
3 Sascha Lefèvre 145
4 _duDE_ 140
0 Sergey Alexandrovich Kryukov 7,675
1 OriginalGriff 7,256
2 Sascha Lefèvre 3,034
3 Maciej Los 2,491
4 Richard Deeming 2,305


Advertise | Privacy | Mobile
Web01 | 2.8.150520.1 | Last Updated 4 Oct 2012
Copyright © CodeProject, 1999-2015
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