473,383 Members | 1,815 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

printing a datagrid

i have a c# asp.net webform that contains a datagrid. the datagrid has a
vertical scroll. i need to give the user the ability to print the datagrid's
entire content (all the rows). IE's print menu prints only the rows that are
currently shown. thanks in advance.

string sqlcmd = sqlSelect + sqlOrder;
DataSet ds = new DataSet();
OracleConnection oraConn = new OracleConnection(connStr);
OracleCommand oraCMD = new OracleCommand(sqlcmd, oraConn);
oraConn.Open();
OracleDataAdapter da = new OracleDataAdapter(oraCMD);
da.Fill(ds);
dgSearchResults.DataSource = ds.Tables[0];
dgSearchResults.DataBind();
dgSearchResults.Visible = true;

where dgSearchResults is the Datagrid
Nov 17 '05 #1
2 4083
hi,

I had a similar problem so what I did was open a new window, copy the grid
content to it and just call window.Print(), here is the code:
//for the printing page:

<script>
function FillPage()
{
var div = document.all["CONTENT"];
var origdiv = window.opener.document.all["TextPanel"];

div.innerHTML = origdiv.innerHTML;
print();
//close();
}
</script>
</head>
<body MS_POSITIONING="GridLayout" onload="FillPage();">
<span id="CONTENT">
</span>

in the parent page just enclose the grid in a div named "TextPanel"
cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation


"Newbie" <Ne****@discussions.microsoft.com> wrote in message
news:0B**********************************@microsof t.com...
i have a c# asp.net webform that contains a datagrid. the datagrid has a
vertical scroll. i need to give the user the ability to print the
datagrid's
entire content (all the rows). IE's print menu prints only the rows that
are
currently shown. thanks in advance.

string sqlcmd = sqlSelect + sqlOrder;
DataSet ds = new DataSet();
OracleConnection oraConn = new OracleConnection(connStr);
OracleCommand oraCMD = new OracleCommand(sqlcmd, oraConn);
oraConn.Open();
OracleDataAdapter da = new OracleDataAdapter(oraCMD);
da.Fill(ds);
dgSearchResults.DataSource = ds.Tables[0];
dgSearchResults.DataBind();
dgSearchResults.Visible = true;

where dgSearchResults is the Datagrid

Nov 17 '05 #2
thanks a lot.

"Ignacio Machin ( .NET/ C# MVP )" wrote:
hi,

I had a similar problem so what I did was open a new window, copy the grid
content to it and just call window.Print(), here is the code:
//for the printing page:

<script>
function FillPage()
{
var div = document.all["CONTENT"];
var origdiv = window.opener.document.all["TextPanel"];

div.innerHTML = origdiv.innerHTML;
print();
//close();
}
</script>
</head>
<body MS_POSITIONING="GridLayout" onload="FillPage();">
<span id="CONTENT">
</span>

in the parent page just enclose the grid in a div named "TextPanel"
cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation


"Newbie" <Ne****@discussions.microsoft.com> wrote in message
news:0B**********************************@microsof t.com...
i have a c# asp.net webform that contains a datagrid. the datagrid has a
vertical scroll. i need to give the user the ability to print the
datagrid's
entire content (all the rows). IE's print menu prints only the rows that
are
currently shown. thanks in advance.

string sqlcmd = sqlSelect + sqlOrder;
DataSet ds = new DataSet();
OracleConnection oraConn = new OracleConnection(connStr);
OracleCommand oraCMD = new OracleCommand(sqlcmd, oraConn);
oraConn.Open();
OracleDataAdapter da = new OracleDataAdapter(oraCMD);
da.Fill(ds);
dgSearchResults.DataSource = ds.Tables[0];
dgSearchResults.DataBind();
dgSearchResults.Visible = true;

where dgSearchResults is the Datagrid


Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: JasmineC | last post by:
Hi there! I'm having some problems printing out my windows form. Here's what I need to do: I need to print a datagrid off a windows form, however the datagrid is bigger than screen. When I tried...
3
by: Randy | last post by:
Hello, I'm trying to get some ideas on this. If you were going to have to print a datagrid control (about 20 columns of data), how would you do it. I'm trying to figure out how to get it to look...
3
by: Randy | last post by:
Hello, I'm trying to print a dataGrid using PrintDocument control. My datagrid has about 23 columns so it is fairly wide. When I use the PrintControl, it prints only the part of the dataGrid that...
4
by: Jay | last post by:
Still can't seem to find a solution to printing a lengthy datagrid on multiple pages including datagrid headeron each page. I am not using Crystal Reports or Reporting Services or VStudio. Any...
5
by: ComputerStop | last post by:
I am attempting to print a datagridview. I have not found any method that works successfully. Has any one been successful with this?
4
by: Fred | last post by:
Hello, datagrids have GridLines, BorderWidth, BorderColor, ItemStyle.CssClass, ShowFooter ... properties, which can be used to customize the way they look when printed, how does one achieve the...
3
by: Jay | last post by:
Hi, I have this problem with DataGrid printing. I have a page which contains only DataGrid. When i try to print the page, only 1st page contains the verticle and horizontal lines of the...
0
by: Jay | last post by:
Hi, I have this problem with DataGrid printing. I have a page which contains only DataGrid. When i try to print the page, only 1st page contains the verticle and horizontal lines of the grid....
5
hussaini
by: hussaini | last post by:
please tell me any 1 printing code in datagrid in visual basic 6 in detail ----- Hello seniors members hope u will tell me ..... i have created a form in visual basic 6 so in the form there is a...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.