hi,
when i try to run the procedure below to export the gridview1 to msword,nothing appears on the document except tags <div> </div>.anyone knows what i might be doing wrong?

Public Overloads Overrides Sub VerifyRenderingInServerForm(ByVal control As Control)
   
      ' Verifies that the control is rendered
  
      End Sub
   
       
   
         Protected Sub ButtonExport_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ButtonExport.Click
         Response.Clear()
         Response.Buffer = True
        Response.AddHeader("content-disposition", "attachment;filename=HoursExport.doc")
        Response.Charset = ""
        Response.ContentType = "application/vnd.msword"
        Dim sw As New StringWriter()
        Dim hw As New HtmlTextWriter(sw)
        GridView1.AllowPaging = False
        GridView1.DataBind()
        GridView1.RenderControl(hw)
        Response.Output.Write(sw.ToString())
        Response.Flush()
        Response.[End]()
      
  
      End Sub

any assistance will be appreciated.

The below code works for me, Can you set content encoding and also can you ensure that MS word is installed on the client side.

Response.Clear();
Response.Buffer = true;

Response.AddHeader("content-disposition", "attachment;filename=FileName.doc");

Response.ContentEncoding = System.Text.Encoding.UTF7;
Response.ContentType = "application/vnd.word";
System.IO.StringWriter oStringWriter = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);
this.GridView1.RenderControl(oHtmlTextWriter);
Response.Output.Write(oStringWriter.ToString());
Response.Flush();
Response.End();

Hi,

Still not working,it just shows the <div> </div> tags in word,any other ideas?
i assign a data source to the gridview in code during execution,could that be the cause?

oh,sory your solution worked,i just removed gridview1.databind(),thanks alot