Help displaying printer friendly DataGrid in new window.

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
 
R

Richard K Bethell

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();
%>
 
R

Ray

My bad. I've seen this example, however I should of mentioned our
client doesn't want us using session variables at all.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,266
Messages
2,571,082
Members
48,773
Latest member
Kaybee

Latest Threads

Top