Click here to Skip to main content
15,917,645 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralClickety Police Pin
Colin Angus Mackay29-Jun-06 21:38
Colin Angus Mackay29-Jun-06 21:38 
GeneralEmail Problem In Asp.Net Pin
sriramaprasad29-Jun-06 22:45
sriramaprasad29-Jun-06 22:45 
GeneralRe: Email Problem In Asp.Net Pin
DIMPLE_R29-Jun-06 23:01
DIMPLE_R29-Jun-06 23:01 
GeneralRe: Email Problem In Asp.Net Pin
sriramaprasad30-Jun-06 2:01
sriramaprasad30-Jun-06 2:01 
QuestionFunctionlity of viewstate Pin
suveenmohan29-Jun-06 20:28
suveenmohan29-Jun-06 20:28 
AnswerRe: Functionlity of viewstate Pin
DIMPLE_R29-Jun-06 20:49
DIMPLE_R29-Jun-06 20:49 
GeneralClickety Police Pin
Colin Angus Mackay29-Jun-06 21:38
Colin Angus Mackay29-Jun-06 21:38 
QuestionMSN Messenger 7.5 Pin
clatterbucket29-Jun-06 20:04
clatterbucket29-Jun-06 20:04 
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 

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.