TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
roy himanshu
NA
126
0
how to print gridview data when i click button in asp?
Nov 26 2009 11:21 PM
pz give the code help me
i got error my code past below
protected
void
Page_Load(
object
sender,
EventArgs
e)
{
SqlConnection
myConnection =
new
SqlConnection
(
"Data Source=HIMANSHU;Initial Catalog=try;Trusted_Connection=yes;"
);
SqlDataAdapter
Sqlad =
new
SqlDataAdapter
(
"SELECT * FROM gri"
, myConnection);
DataSet
dsSupplier =
new
DataSet
();
Sqlad.Fill(dsSupplier);
GridView1.DataBind();
}
protected
void
Button1_Click(
object
sender,
EventArgs
e)
{
Response.Clear();
Response.AddHeader(
"content-disposition"
,
"attachment; filename=SupplierList.xls"
);
Response.ContentType =
"
application
/vnd.xls"
;
System.IO.
StringWriter
WriteItem =
new
System.IO.
StringWriter
();
System.Web.UI.
HtmlTextWriter
htmlText =
new
HtmlTextWriter
(WriteItem);
GridView1.RenderControl(htmlText);
Response.Write(WriteItem.ToString());
Response.End();
}
i got below error
Control 'GridView1' of type 'GridView' must be placed inside a form tag with runat=
server
.
plz help me
Reply
Answers (
1
)
how to print gridview data when i click a button?
add rows to the data gridview one by one on clicking a button at run time . how can i do it in c#.