Try to change the page directives like the following and run...
Else Just remove the button1 click event and try to double click on the button in the design mode and get where it placing the event in the code behind file.
CodeBehind = Needs to be compiled ( asp.net 1.1 model) and compiled binary is placed in the bin folder of the website. You need to do a compile in visual studio before you deploy. Good model when you do not want the source code to be viewable as plain text
... for example when delivering to a customer who you not have obligation to provide code.
CodeFile = You provide the source file with the solution for deployment. ASP.NET 2.0 runtime compiles the code when needed. The compiled files are at Microsfot.NET[.NET version]\Temporary ASP.NET Files.
Parthasarathi,
Remember to click Mark as Answer on the post that helps to others.
sarathi125
Star
13599 Points
2691 Posts
Re: Export Binded Gridview to Any Doc (Excel or Word or Any format)
Jan 05, 2013 02:10 PM|LINK
Hi,
Try to change the page directives like the following and run...
Else Just remove the button1 click event and try to double click on the button in the design mode and get where it placing the event in the code behind file.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="ExportGridView._Default" %>
Remember to click Mark as Answer on the post that helps to others.
My Blog :MyAspSnippets
n2adn_India
Member
15 Points
75 Posts
Re: Export Binded Gridview to Any Doc (Excel or Word or Any format)
Jan 05, 2013 03:02 PM|LINK
Excellent Mate,
When I change the Design to File, its worked well.
What is the reason?
sarathi125
Star
13599 Points
2691 Posts
Re: Export Binded Gridview to Any Doc (Excel or Word or Any format)
Jan 05, 2013 03:12 PM|LINK
Hi,
This is the difference...
CodeBehind = Needs to be compiled ( asp.net 1.1 model) and compiled binary is placed in the bin folder of the website. You need to do a compile in visual studio before you deploy. Good model when you do not want the source code to be viewable as plain text ... for example when delivering to a customer who you not have obligation to provide code.
CodeFile = You provide the source file with the solution for deployment. ASP.NET 2.0 runtime compiles the code when needed. The compiled files are at Microsfot.NET[.NET version]\Temporary ASP.NET Files.
Remember to click Mark as Answer on the post that helps to others.
My Blog :MyAspSnippets
Anil Srivast...
Member
442 Points
292 Posts
Re: Export Binded Gridview to Any Doc (Excel or Word or Any format)
Jan 06, 2013 03:39 AM|LINK
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="Default.aspx.cs" Inherits="ExportGridView._Default" %>
<html>
<head>
<title>ExportGridView</title>
</head>
<body>
<form id="Form1" runat="server">
<asp:Label ID="lbl" runat="server"></asp:Label>
<asp:GridView ID="maingrid" runat="server" AutoGenerateColumns="false">
<Columns>
<asp:TemplateField HeaderText="ID">
<ItemTemplate>
<asp:Label ID="gridid" runat="server" Text='<% #bind("id") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="NAME">
<ItemTemplate>
<asp:Label ID="gridname" runat="server" Text='<% #bind("name") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:Button ID="btn1" runat="server" Text="Export 2 Excel" onclick="btn1_Click"/>
<asp:Button ID="btn2" runat="server" Text="Export 2 Word" onclick="btn2_Click"
Height="26px"/>
<asp:Button ID="btn3" runat="server" Text="Export 2 PDF" onclick="btn3_Click"/>
</form>
</body>
</html>
n2adn_India
Member
15 Points
75 Posts
Re: Export Binded Gridview to Any Doc (Excel or Word or Any format)
Jan 06, 2013 04:46 AM|LINK
Thanks Anil, I already solve the problem, You make my button inside the form but actual problem is I need to change codeBehind to CodeFile.