Click here to Skip to main content
16,015,923 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionASP.NET host with MySQL Pin
Jassim Rahma19-Nov-10 23:08
Jassim Rahma19-Nov-10 23:08 
QuestionWeb Service from a WCF Service using HttpPost Pin
indian14319-Nov-10 10:34
indian14319-Nov-10 10:34 
AnswerRe: Web Service from a WCF Service using HttpPost Pin
GlobX24-Nov-10 14:26
GlobX24-Nov-10 14:26 
QuestionFix my read file permission error now! [modified] Pin
musefan19-Nov-10 0:22
musefan19-Nov-10 0:22 
AnswerRe: Fix my read file permission error now! Pin
Chris Maunder19-Nov-10 0:42
cofounderChris Maunder19-Nov-10 0:42 
GeneralRe: Fix my read file permission error now! [modified] Pin
musefan19-Nov-10 0:51
musefan19-Nov-10 0:51 
AnswerAnswer Pin
musefan21-Nov-10 23:50
musefan21-Nov-10 23:50 
QuestionHow to end a request if there are no records to display Pin
meeram39518-Nov-10 16:55
meeram39518-Nov-10 16:55 
I have a page which runs a dynamic sql query, gets the output and show the output in an excel file on the spot. Everything is working fine.

Issue is, whenever, there is no records to show, even the process is completed, the browser seems to be still running. I can see the icon at the top is rounding with the word "Connecting....". I tried use Response.End and Response.Flush. But still the same scenario.

I want to end the process and give a message saying that No records found. Even though message is given,it's not displaying in the label.

Following is my code for export to excel:
private void ExporttoExcel(string xmlPath)
       {

           HttpResponse response = HttpContext.Current.Response;

           // first let's clean up the response.object
           response.Clear();
           response.Charset = "";
           // set the response mime type for excel
           response.ContentType = "application/ms-excel";

           DataSet xportdata = new DataSet();
           xportdata.ReadXml(xmlPath);

           if (xportdata != null)
           {
               if (xportdata.Tables.Count > 0)
               {
                   if (xportdata.Tables[0].Rows.Count > 0)
                   {

                       StringWriter sw = new StringWriter();
                       HtmlTextWriter htw = new HtmlTextWriter(sw);
                       GridView gv = new GridView();
                       gv.DataSource = xportdata.Tables[0];
                       gv.DataBind();
                       gv.RenderControl(htw);
                       Response.Write(sw.ToString());
                       Response.End();
                   }
                   else
                   {
                       lblErrorMessage.Text = "No Records Found.";
                   }
               }
               else
               {
                   lblErrorMessage.Text = "No Records Found.";
                   Response.Flush();
                   //Response.End();
               }
           }
       }


Am I using something wrong here? Could anybody please help me on this.

Thanks
Success is the good fortune that comes from aspiration, desperation, perspiration and inspiration.

AnswerRe: How to end a request if there are no records to display Pin
Not Active18-Nov-10 17:12
mentorNot Active18-Nov-10 17:12 
AnswerRe: How to end a request if there are no records to display Pin
surender.m18-Nov-10 23:23
surender.m18-Nov-10 23:23 
QuestionExtract data for a form using web performance test tool visual studio Pin
jboyd11118-Nov-10 12:10
jboyd11118-Nov-10 12:10 
Questioncheckboxlist validator Pin
Dhyanga18-Nov-10 5:51
Dhyanga18-Nov-10 5:51 
AnswerRe: checkboxlist validator Pin
Not Active18-Nov-10 6:44
mentorNot Active18-Nov-10 6:44 
GeneralRe: checkboxlist validator Pin
Dhyanga18-Nov-10 6:47
Dhyanga18-Nov-10 6:47 
GeneralRe: checkboxlist validator Pin
Dhyanga18-Nov-10 8:33
Dhyanga18-Nov-10 8:33 
GeneralRe: checkboxlist validator Pin
Not Active18-Nov-10 14:29
mentorNot Active18-Nov-10 14:29 
QuestionCall Javascript function when gridview loads Pin
Satish_S18-Nov-10 1:06
Satish_S18-Nov-10 1:06 
AnswerRe: Call Javascript function when gridview loads Pin
NeverHeardOfMe18-Nov-10 2:54
NeverHeardOfMe18-Nov-10 2:54 
QuestionAjax Controls(Collapsable panel) Not working on .Netframework 3.5 Pin
Raveendra.jonna17-Nov-10 23:13
Raveendra.jonna17-Nov-10 23:13 
AnswerRe: Ajax Controls(Collapsable panel) Not working on .Netframework 3.5 Pin
T M Gray18-Nov-10 7:04
T M Gray18-Nov-10 7:04 
GeneralRe: Ajax Controls(Collapsable panel) Not working on .Netframework 3.5 Pin
Raveendra.jonna18-Nov-10 17:40
Raveendra.jonna18-Nov-10 17:40 
GeneralRe: Ajax Controls(Collapsable panel) Not working on .Netframework 3.5 Pin
Not Active18-Nov-10 18:43
mentorNot Active18-Nov-10 18:43 
GeneralRe: Ajax Controls(Collapsable panel) Not working on .Netframework 3.5 [modified] Pin
Raveendra.jonna18-Nov-10 18:52
Raveendra.jonna18-Nov-10 18:52 
QuestionImages not visible after publishing the web application Pin
stambekar17-Nov-10 19:36
stambekar17-Nov-10 19:36 
AnswerRe: Images not visible after publishing the web application Pin
surender.m18-Nov-10 23:34
surender.m18-Nov-10 23:34 

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.