Help displaying printer friendly DataGrid in new window.

  • Thread starter Thread starter Ray
  • Start date Start date
R

Ray

ASP.NET Newbie ?

I have a populated datagrid on my .aspx page, I want to open a second
window without all the extra fluff (nav bar, menus, etc) and display a
printer friendly version of my datagrid. I'm looking for ideas on how
to pass the data to the second page without making a second request
back to the database? Passing the data as a dialog argument in a
window.ShowModelDialog is really not an option because of the possible
data size.

Thanks in advance,
Ray
 
Ray said:
ASP.NET Newbie ?

I have a populated datagrid on my .aspx page, I want to open a second
window without all the extra fluff (nav bar, menus, etc) and display a
printer friendly version of my datagrid. I'm looking for ideas on how
to pass the data to the second page without making a second request
back to the database? Passing the data as a dialog argument in a
window.ShowModelDialog is really not an option because of the possible
data size.

If you are worried about expensive session variables, here is how you can
use them and minimize the cost. In the first page, assign the datasource
(whether it is a DataTable, hashtable, or whatever) to a session variable.
Then in the second page, unbox the session variable, assign it to the
datagrid, bind it, and then destroy the session variable.

i.e. and I'm just typing this not compiling it, so forgive me any C# typos
or oversights:

Page 1
<%
DataTable MyTable = new DataTable("tblFred");
MyTable.Columns.Add("Name");
DataRow dr = dt.NewRow();
dr["Name"] = "Fred Flinstone";
dt.Rows.Add(dr);
Session["tblFred"] = dt;
//clean up and binding code, etc.
%>

Page 2 (Friendly print page)
<%
DataTable dt;
dt = (DataTable)Session["tblFred"];
MyGrid.DataSource = dt;
Page.DataBind();
Session["tblFred"] = null;
dt.Dispose();
%>
 
My bad. I've seen this example, however I should of mentioned our
client doesn't want us using session variables at all.
 
Back
Top