Click here to Skip to main content
15,899,475 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionUsing singleton classes in ASP.Net Pin
jnaude7-Nov-07 23:48
jnaude7-Nov-07 23:48 
AnswerRe: Using singleton classes in ASP.Net Pin
N a v a n e e t h7-Nov-07 23:56
N a v a n e e t h7-Nov-07 23:56 
AnswerRe: Using singleton classes in ASP.Net Pin
Guffa8-Nov-07 2:22
Guffa8-Nov-07 2:22 
GeneralRe: Using singleton classes in ASP.Net Pin
Colin Angus Mackay8-Nov-07 4:35
Colin Angus Mackay8-Nov-07 4:35 
AnswerRe: Using singleton classes in ASP.Net Pin
Guffa8-Nov-07 5:25
Guffa8-Nov-07 5:25 
GeneralRe: Using singleton classes in ASP.Net Pin
Colin Angus Mackay8-Nov-07 6:41
Colin Angus Mackay8-Nov-07 6:41 
AnswerRe: Using singleton classes in ASP.Net Pin
Paddy Boyd8-Nov-07 2:43
Paddy Boyd8-Nov-07 2:43 
QuestionASP export to excel and Ajax problem Pin
Herman<T>.Instance7-Nov-07 23:24
Herman<T>.Instance7-Nov-07 23:24 
Hi!

In a website we generate a drilldown report from a GridView component. With Javascript the onclick functionality is added and works fine.

We generate a DataTable depending on rownumber and columnnumber from the click.
As soon as we have the data in the DataTable we export the DataTable to Excel. Works fine.
If i Close Excel and want to click on a button in the webpage (Run Report-button) I get again the same Excel as I just Closed.
Somehow my webpage is out of sync.
How do I get in InSync again?

Method to send the DataTable to an aspx file for exporting to Excel:
private void DrillDown(DataTable drillDown)
    {
        try
        {
            Page.Session.Add("excelTable", drillDown);
            Page.Session.Add("excelName", "DrillDownClaimsReport");
            Page.Session.Add("returnPageAfterExport", "../Reports/ClaimReport.aspx");
            Response.Redirect("../Export/DataTableToExcel.aspx");
        }
        catch (Exception err)
        {
            lblError.Text = err.Message;
        }
    }


Page DataTableToExcel.aspx.cs:
using System;
using System.IO;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Export_DataTableToExcel : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        DataTable excelTable = new DataTable();
        String excelName = String.Empty;
        String returnPage = String.Empty;
        excelTable = (DataTable)Page.Session["excelTable"];
        excelName = (string)Page.Session["excelName"];
        returnPage = (string)Page.Session["returnPageAfterExport"];
        ExportDataTableToExcel(excelTable, excelName, returnPage);
    }

    private void ExportDataTableToExcel(DataTable table, String fileName, String returnPage)
    {
        // Export function to excel. Should work without any Excel dll's now, so stand-alone.

        Response.Clear();
        Response.AddHeader("content-disposition", String.Format("attachment;filename={0}.xls", fileName));

        Response.ContentType = "application/ms-excel";
        //Response.ContentType = "application/vnd.ms-excel";
        Response.Charset = "iso-8859-1";
        String Combineer = String.Empty;

        String sep = String.Empty;
        foreach (DataColumn dc in table.Columns)
        {
            Combineer += sep + dc.ColumnName.Replace("_", " ").Replace("occurrence date", "Date of Loss");
            sep = "\t";
        }
        Combineer += "\n";

        int i;
        foreach (DataRow dr in table.Rows)
        {
            sep = String.Empty;
            for (i = 0; i < table.Columns.Count; i++)
            {
                Combineer += sep + dr[i].ToString();
                sep = "\t";
            }
            Combineer += "\n";
        }
        Response.Write(Combineer);
        Response.End();
        Page.Session.Remove("excelTable");
        Page.Session.Remove("excelName");
        Page.Session.Remove("returnPageAfterExport");
        Response.Redirect(returnPage);
    }
}


Help Needed!!!
Questiongetting started in AJAX Pin
Ahmad Adnan7-Nov-07 23:20
Ahmad Adnan7-Nov-07 23:20 
AnswerRe: getting started in AJAX Pin
Christian Graus7-Nov-07 23:31
protectorChristian Graus7-Nov-07 23:31 
AnswerRe: getting started in AJAX Pin
N a v a n e e t h7-Nov-07 23:33
N a v a n e e t h7-Nov-07 23:33 
QuestionCreating a store in eBay's Sandbox through eBay SDK [modified] Pin
Rocky#7-Nov-07 22:22
Rocky#7-Nov-07 22:22 
AnswerRe: Creating a store in eBay's Sandbox through eBay SDK Pin
N a v a n e e t h7-Nov-07 22:27
N a v a n e e t h7-Nov-07 22:27 
GeneralRe: Creating a store in eBay's Sandbox through eBay SDK Pin
Rocky#7-Nov-07 22:31
Rocky#7-Nov-07 22:31 
QuestionFocus on top of page when any error occurs after validation... Pin
Pushpa Setty7-Nov-07 22:18
Pushpa Setty7-Nov-07 22:18 
QuestionRaise an synchronous post back by javacript function in asp.net ajax [modified] Pin
boidolaem7-Nov-07 21:57
boidolaem7-Nov-07 21:57 
AnswerRe: Raise an synchronous post back by javacript function in asp.net ajax Pin
Michael Sync8-Nov-07 19:55
Michael Sync8-Nov-07 19:55 
GeneralRe: Raise an synchronous post back by javacript function in asp.net ajax Pin
boidolaem11-Nov-07 22:42
boidolaem11-Nov-07 22:42 
Questiona gridview without any datasource Pin
sayonifahim7-Nov-07 21:54
sayonifahim7-Nov-07 21:54 
AnswerRe: a gridview without any datasource Pin
N a v a n e e t h7-Nov-07 22:17
N a v a n e e t h7-Nov-07 22:17 
AnswerRe: a gridview without any datasource Pin
M_Menon8-Nov-07 1:58
M_Menon8-Nov-07 1:58 
AnswerRe: a gridview without any datasource Pin
surer8-Nov-07 4:10
surer8-Nov-07 4:10 
Questionhow to perform click event on dynamically created bottons Pin
yogesh_softworld1237-Nov-07 20:45
yogesh_softworld1237-Nov-07 20:45 
AnswerRe: how to perform click event on dynamically created bottons Pin
Guffa7-Nov-07 20:48
Guffa7-Nov-07 20:48 
AnswerRe: how to perform click event on dynamically created bottons Pin
Christian Graus7-Nov-07 22:31
protectorChristian Graus7-Nov-07 22:31 

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.