Click here to Skip to main content
15,902,635 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionHow to create feedbackform in ASP.Net using C# Pin
somya12229-Jun-06 19:45
somya12229-Jun-06 19:45 
AnswerRe: How to create feedbackform in ASP.Net using C# Pin
Amit Agarrwal29-Jun-06 20:19
Amit Agarrwal29-Jun-06 20:19 
GeneralRe: How to create feedbackform in ASP.Net using C# Pin
Murali xten8-May-13 21:15
professionalMurali xten8-May-13 21:15 
AnswerRe: How to create feedbackform in ASP.Net using C# Pin
Muhammad Chitrali30-Jun-06 3:48
Muhammad Chitrali30-Jun-06 3:48 
Questionconvert the site info into Xml format Pin
Amit Agarrwal29-Jun-06 19:08
Amit Agarrwal29-Jun-06 19:08 
QuestionTime Converting From Database Pin
varshavmane29-Jun-06 19:02
varshavmane29-Jun-06 19:02 
QuestionCreating Excel file from dataset data [modified] Pin
Dhruvil29-Jun-06 18:21
Dhruvil29-Jun-06 18:21 
AnswerRe: Creating Excel file from dataset data [modified] Pin
ketankumar29-Jun-06 20:17
ketankumar29-Jun-06 20:17 
Hello Niki,

You can create excel file on the fly. I have posted in my previous message that how to create excel file on the file and give to user for download.

First of all you need to generate html code in table format from dataset.I am writing the code for that as well.

----------------------------------------------------------------------
//Write a table structure from dataset

//Suppose your dataset name is ds then write following code on click event of hyperlink:

string strHtml = "<table border='1' cellspacing='0' cellpadding='0'>";
DataTable dt = ds.Tables(0);
foreach(DataRow dr in dt.Rows)
{
strHtml+="<tr>";
for(int i=0;i<dt.Columns.Count;i++)
{
strHtml+="<td>" + dr[i].ToString() + "</td>";
}
strHtml+="</tr>";
}
strHtml+="</table>";

//Clear the Response Headers
Response.Clear();

Response.Charset = String.Empty; // String.Empty();

//Set Content Type and add header
Response.ContentType = "application/vnd.ms-excel";

//Add Header to create a file on the fly, give file name also. (i.e. abc.xls)
Response.AddHeader("Content-Disposition", "attachment; filename=abc.xls;");
this.EnableViewState = false;

//Declare new HtmlTextWriter
System.IO.StringWriter myTextWriter = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter myHtmlTextWriter = new System.Web.UI.HtmlTextWriter(myTextWriter);

//Declare new HtmlGenericControl and feed it with the strHtml
HtmlGenericControl gn = new HtmlGenericControl();
gn.InnerHtml=strHtml;

//Finally render the HtmlGenericControl to Response
gn.RenderControl( myHtmlTextWriter);
Response.Write(myTextWriter.ToString());
Response.End();
----------------------------------------------------------------------

Regards,
Ketan.

-- modified at 7:30 Wednesday 5th July, 2006
GeneralRe: Creating Excel file from dataset data Pin
Dhruvil30-Jun-06 2:54
Dhruvil30-Jun-06 2:54 
GeneralRe: Creating Excel file from dataset data Pin
ketankumar30-Jun-06 3:10
ketankumar30-Jun-06 3:10 
GeneralRe: Creating Excel file from dataset data Pin
Dhruvil30-Jun-06 5:34
Dhruvil30-Jun-06 5:34 
GeneralRe: Creating Excel file from dataset data Pin
ketankumar1-Jul-06 23:39
ketankumar1-Jul-06 23:39 
Questionproblem with inheriring a page Pin
sishya29-Jun-06 15:31
sishya29-Jun-06 15:31 
AnswerRe: problem with inheriring a page Pin
minhpc_bk29-Jun-06 17:06
minhpc_bk29-Jun-06 17:06 
AnswerRe: problem with inheriring a page Pin
Guffa29-Jun-06 19:02
Guffa29-Jun-06 19:02 
GeneralBut the placeholder control is declared in the code behind class also . Pin
sishya29-Jun-06 19:15
sishya29-Jun-06 19:15 
AnswerRe: But the placeholder control is declared in the code behind class also . Pin
Guffa29-Jun-06 19:40
Guffa29-Jun-06 19:40 
QuestionManage a GridView's HyperLinkField column's width? [modified] Pin
-Dr_X-29-Jun-06 10:24
-Dr_X-29-Jun-06 10:24 
AnswerRe: Manage a GridView's HyperLinkField column's width? Pin
minhpc_bk29-Jun-06 17:02
minhpc_bk29-Jun-06 17:02 
GeneralRe: Manage a GridView's HyperLinkField column's width? Pin
-Dr_X-5-Jul-06 7:09
-Dr_X-5-Jul-06 7:09 
QuestionSession [modified] Pin
kirthikirthi29-Jun-06 9:04
kirthikirthi29-Jun-06 9:04 
AnswerRe: Session Pin
Guffa29-Jun-06 11:44
Guffa29-Jun-06 11:44 
AnswerRe: Session Pin
minhpc_bk29-Jun-06 17:08
minhpc_bk29-Jun-06 17:08 
Questionhow to work with multiple web forms Pin
ravindradonkada29-Jun-06 8:32
ravindradonkada29-Jun-06 8:32 
AnswerRe: how to work with multiple web forms [modified] Pin
eggsovereasy29-Jun-06 9:40
eggsovereasy29-Jun-06 9:40 

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.