Link to home
Start Free TrialLog in
Avatar of SirReadAlot
SirReadAlot

asked on

export to excel without pagination links

Hi experts,

how can i export to xls without pagination links

this is my code

private void ExportGridView()
    {
        string attachment = "attachment; filename=FileName.xls";
        Response.ClearContent();
        Response.AddHeader("content-disposition", attachment);
        Response.ContentType = "application/ms-excel";
        StringWriter sw = new StringWriter();
        HtmlTextWriter htw = new HtmlTextWriter(sw);

        // Create a form to contain the grid
        HtmlForm frm = new HtmlForm();
        gvBMSEmps.Parent.Controls.Add(frm);
        frm.Attributes["runat"] = "server";
        frm.Controls.Add(gvBMSEmps);
        frm.RenderControl(htw);

        Response.Write(sw.ToString());
        Response.End();
    }


    public override void VerifyRenderingInServerForm(Control control)
    {

    }


    private void PrepareGridViewForExport(Control gv)
    {
      //  LinkButton lb = new LinkButton();
        Literal l = new Literal();
        string name = String.Empty;
        for (int i = 0; i < gv.Controls.Count; i++)
        {

            if (gv.Controls[i].GetType() == typeof(LinkButton))
            {
                l.Text = (gv.Controls[i] as LinkButton).Text;

                gv.Controls.Remove(gv.Controls[i]);

                gv.Controls.AddAt(i, l);

            }
               PrepareGridViewForExport(gv.Controls[i]);
                   
        }
    }
}

thanks
ASKER CERTIFIED SOLUTION
Avatar of SirReadAlot
SirReadAlot

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of SirReadAlot
SirReadAlot

ASKER

can't find visible or enabled in

 gridview