Click here to Skip to main content
15,918,041 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: Limit size of pictures for upload in my web site (VS2010 – C#) Pin
Not Active24-May-12 2:11
mentorNot Active24-May-12 2:11 
AnswerRe: Limit size of pictures for upload in my web site (VS2010 – C#) Pin
Jack Li24-May-12 5:14
Jack Li24-May-12 5:14 
AnswerRe: Limit size of pictures for upload in my web site (VS2010 – C#) Pin
jkirkerx25-May-12 7:42
professionaljkirkerx25-May-12 7:42 
QuestionDon’t Export Persian fields finely from ASP.NET to Excel (VS2010 – C#) Pin
armm138823-May-12 18:38
armm138823-May-12 18:38 
GeneralRe: Don’t Export Persian fields finely from ASP.NET to Excel (VS2010 – C#) Pin
Not Active24-May-12 2:08
mentorNot Active24-May-12 2:08 
AnswerRe: Don’t Export Persian fields finely from ASP.NET to Excel (VS2010 – C#) Pin
Jack Li24-May-12 5:21
Jack Li24-May-12 5:21 
GeneralRe: Don’t Export Persian fields finely from ASP.NET to Excel (VS2010 – C#) Pin
Not Active24-May-12 5:53
mentorNot Active24-May-12 5:53 
AnswerRe: Don’t Export Persian fields finely from ASP.NET to Excel (VS2010 – C#) Pin
Not Active24-May-12 5:50
mentorNot Active24-May-12 5:50 
You don't export the GridView, you export the DataSource of the GridView.

Assuming you are using a DataTable as the DatSource

C#
StringBuilder sb = new StringBuilder();
List<string> rows = new List<string>();
foreach(DataColumn col in DataSource.Columns)
{
    rows.Add(col.ColumnName);
}

sb.AppendLine(string.Join(",", rows.ToArray()));
rows.Clear();
foreach(DataRow row in DataSource.Rows)
{
    foreach(object item in row.ItemArray)
    {
        rows.Add(item.ToString());
    }
    sb.AppendLine(string.Join(",", rows.ToArray()));
    rows.Clear();
}

Response.ContentType = "Application/x-msexcel";
Response.AddHeader("content-disposition", "attachment;filename=export.csv");
Response.Clear();
using(StreamWriter writer = new StreamWriter(Response.OutputStream, Encoding.UTF8))
{
    writer.Write(sb.ToString());
}
Response.End();


Failure is not an option; it's the default selection.

QuestionSystem.OutOfMemoryException Pin
rakeshkmr198523-May-12 9:05
rakeshkmr198523-May-12 9:05 
AnswerRe: System.OutOfMemoryException Pin
jkirkerx23-May-12 9:20
professionaljkirkerx23-May-12 9:20 
AnswerRe: System.OutOfMemoryException Pin
Fabio Franco24-May-12 2:30
professionalFabio Franco24-May-12 2:30 
AnswerRe: System.OutOfMemoryException Pin
RichardGrimmer25-May-12 4:24
RichardGrimmer25-May-12 4:24 
QuestionXML tag & recordset not working in firefox Pin
Member 819658023-May-12 1:19
Member 819658023-May-12 1:19 
AnswerRe: XML tag & recordset not working in firefox Pin
jkirkerx23-May-12 9:16
professionaljkirkerx23-May-12 9:16 
QuestionCheck for repeated characters Pin
padmanabhan N22-May-12 22:10
padmanabhan N22-May-12 22:10 
AnswerRe: Check for repeated characters Pin
Not Active23-May-12 2:32
mentorNot Active23-May-12 2:32 
AnswerRe: Check for repeated characters Pin
jkirkerx23-May-12 13:01
professionaljkirkerx23-May-12 13:01 
GeneralRe: Check for repeated characters Pin
Not Active23-May-12 13:16
mentorNot Active23-May-12 13:16 
GeneralRe: Check for repeated characters Pin
jkirkerx24-May-12 5:10
professionaljkirkerx24-May-12 5:10 
AnswerRe: Check for repeated characters Pin
markovl23-May-12 21:07
markovl23-May-12 21:07 
QuestionScope For Hospital Management Pin
santosh_pathak22-May-12 21:51
santosh_pathak22-May-12 21:51 
AnswerRe: Scope For Hospital Management Pin
Sandeep Mewara22-May-12 23:44
mveSandeep Mewara22-May-12 23:44 
GeneralRe: Scope For Hospital Management Pin
santosh_pathak23-May-12 0:13
santosh_pathak23-May-12 0:13 
AnswerCross posted from design forum Pin
Pete O'Hanlon23-May-12 0:20
mvePete O'Hanlon23-May-12 0:20 
QuestionVSTO Pin
Ramkumar_S22-May-12 19:49
Ramkumar_S22-May-12 19:49 

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.