Click here to Skip to main content
15,896,915 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: Client side scripting (Ajax): filling gridviews Pin
Andre Teunissen12-Jun-07 23:17
Andre Teunissen12-Jun-07 23:17 
QuestionImporting Pin
A kamath12-Jun-07 22:48
A kamath12-Jun-07 22:48 
AnswerRe: Importing Pin
Sylvester george12-Jun-07 23:23
Sylvester george12-Jun-07 23:23 
GeneralRe: Importing Pin
A kamath12-Jun-07 23:28
A kamath12-Jun-07 23:28 
GeneralRe: Importing Pin
Sylvester george12-Jun-07 23:36
Sylvester george12-Jun-07 23:36 
AnswerRe: FYI :: Openings in an MNC Pin
Colin Angus Mackay12-Jun-07 22:17
Colin Angus Mackay12-Jun-07 22:17 
QuestionSysRefCursor in asp.net Pin
Sapan Roy12-Jun-07 21:48
Sapan Roy12-Jun-07 21:48 
QuestionExcel Conversion Error Pin
DKalepu12-Jun-07 20:46
DKalepu12-Jun-07 20:46 
Hi All,

I need some help. I'm trying to export Gridview into Excel. But i'm getting the following error!

"Control 'myGridView' of type 'GridView' must be placed inside a form tag with runat=server."

Here is my Code:

protected void BtnExport_Click(object sender, EventArgs e)
{
Response.Clear();
Response.AddHeader("content-disposition", "attachment;filename=FileName.xls");
Response.Charset = "";

// If you want the option to open the Excel file without saving then
// comment out the line below
// Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.ContentType = "application/ms-excel.xls";
System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
myGridView.RenderControl(htmlWrite);
Response.Write(stringWrite.ToString());
Response.End();
}

THIS IS THE GRIDVIEW THAT I'M USING::
<asp:gridview id="myGridView" runat="server" width="483px" cellpadding="4" forecolor="#333333" autogeneratecolumns="False" datasourceid="AccessDataSource1">
<columns>
<asp:boundfield datafield="Sno" headertext="SNo" sortexpression="Sno">
<asp:boundfield datafield="Partno" headertext="PartNo" sortexpression="Partno">
<asp:boundfield datafield="mfg" headertext="Manufacturer" sortexpression="mfg">
<asp:boundfield datafield="qty" headertext="Quantity" sortexpression="qty">
<asp:boundfield datafield="price" headertext="Price" sortexpression="price">

<footerstyle backcolor="#507CD1" font-bold="True" forecolor="White">
<rowstyle backcolor="#EFF3FB">
<editrowstyle backcolor="#2461BF">
<selectedrowstyle backcolor="#D1DDF1" font-bold="True" forecolor="#333333">
<pagerstyle backcolor="#2461BF" forecolor="White" horizontalalign="Center">
<headerstyle backcolor="#507CD1" font-bold="True" forecolor="White">
<alternatingrowstyle backcolor="White">

<asp:accessdatasource id="AccessDataSource1" runat="server" datafile="~/App_Data/db1.mdb"
="" selectcommand="SELECT [Sno], [Partno], [mfg], [qty], [price] FROM [RfqInfo]">

But my Gridview is already placed in the form only!!!!Cry | :(( Confused | :confused:

could any one please help me on this issue???

Thanks in Advance.
AnswerRe: Excel Conversion Error Pin
_AK_12-Jun-07 20:49
_AK_12-Jun-07 20:49 
AnswerRe: Excel Conversion Error Pin
Sathesh Sakthivel12-Jun-07 20:51
Sathesh Sakthivel12-Jun-07 20:51 
GeneralRe: Excel Conversion Error Pin
_AK_12-Jun-07 20:53
_AK_12-Jun-07 20:53 
GeneralRe: Excel Conversion Error Pin
Sathesh Sakthivel12-Jun-07 20:56
Sathesh Sakthivel12-Jun-07 20:56 
AnswerRe: Excel Conversion Error Pin
DKalepu12-Jun-07 20:57
DKalepu12-Jun-07 20:57 
GeneralRe: Excel Conversion Error Pin
_AK_12-Jun-07 20:59
_AK_12-Jun-07 20:59 
GeneralRe: Excel Conversion Error Pin
DKalepu12-Jun-07 21:04
DKalepu12-Jun-07 21:04 
GeneralRe: Excel Conversion Error Pin
_AK_12-Jun-07 21:10
_AK_12-Jun-07 21:10 
GeneralRe: Excel Conversion Error Pin
DKalepu12-Jun-07 21:15
DKalepu12-Jun-07 21:15 
GeneralRe: Excel Conversion Error Pin
DKalepu12-Jun-07 21:17
DKalepu12-Jun-07 21:17 
AnswerRe: Excel Conversion Error Pin
Jay_se12-Jun-07 21:22
Jay_se12-Jun-07 21:22 
GeneralRe: Excel Conversion Error Pin
Venkatesh Mookkan12-Jun-07 22:23
Venkatesh Mookkan12-Jun-07 22:23 
GeneralRe: Excel Conversion Error [modified] Pin
Jay_se12-Jun-07 23:29
Jay_se12-Jun-07 23:29 
AnswerRe: Excel Conversion Error Pin
Venkatesh Mookkan12-Jun-07 21:31
Venkatesh Mookkan12-Jun-07 21:31 
GeneralRe: Excel Conversion Error Pin
Jay_se12-Jun-07 21:37
Jay_se12-Jun-07 21:37 
GeneralRe: Excel Conversion Error Pin
Venkatesh Mookkan12-Jun-07 21:41
Venkatesh Mookkan12-Jun-07 21:41 
AnswerRe: Excel Conversion Error Pin
DKalepu12-Jun-07 21:47
DKalepu12-Jun-07 21:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.