473,395 Members | 1,581 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,395 software developers and data experts.

Printing a report from a datagrid.

Hi,

I am relatively new to Visual Studio.NET (i am using VB), I have
created a datagrid which I have bound to a SQL database, when I browse
the form with the datagrid it displays all the columns as expeced using
the following code:

If Not IsPostBack Then
SqlConnection1.Open()
Dim Reader As SqlClient.SqlDataReader
Reader = SqlCommand1.ExecuteReader()
DataGrid1.DataSource = Reader
DataGrid1.DataBind()
Reader.Close()
SqlConnection1.Close()

I now want to be able to select a row, either by clicking a checkbox
(if it's possible to add a checkbox to a datagrid) or using the select
button and then display the data from that row in a new page in a
format that is printable, I just need to know how to launch the
selected item in the datagrid to a new page. I'm pretty sure I'll be ok
with populating the new page with the data using labels, then having a
print button to print the page.

Any help would be appreciated.

Matt.

Nov 19 '05 #1
5 1198
Hi Mattyw,

The easy way is to add a ButtonColumn to the datagrid and
manipulate data process in datagrid_ItemCommand event. In
the event, you can use e.Item.Cells(colIndex).Text to
collect data for each column in the selected (clicked)
row. Or since you want to process the data in a new page,
you can save the e.Item (DataGridItem) in SessionState. In
the process page, you can retrieve the DataGridItem from
SessionSate, and get data from the DataGridItem.
HTH

Elton Wang
el********@hotmail.com

-----Original Message-----
Hi,

I am relatively new to Visual Studio.NET (i am using VB), I havecreated a datagrid which I have bound to a SQL database, when I browsethe form with the datagrid it displays all the columns as expeced usingthe following code:

If Not IsPostBack Then
SqlConnection1.Open()
Dim Reader As SqlClient.SqlDataReader
Reader = SqlCommand1.ExecuteReader()
DataGrid1.DataSource = Reader
DataGrid1.DataBind()
Reader.Close()
SqlConnection1.Close()

I now want to be able to select a row, either by clicking a checkbox(if it's possible to add a checkbox to a datagrid) or using the selectbutton and then display the data from that row in a new page in aformat that is printable, I just need to know how to launch theselected item in the datagrid to a new page. I'm pretty sure I'll be okwith populating the new page with the data using labels, then having aprint button to print the page.

Any help would be appreciated.

Matt.

.

Nov 19 '05 #2
Multi-Select Using Check Boxes
http://www.geocities.com/jeff_louie/net_checkbox.htm
Regards,
Jeff
(if it's possible to add a checkbox to a datagrid)

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 19 '05 #3

Jeff Louie wrote:
Multi-Select Using Check Boxes
http://www.geocities.com/jeff_louie/net_checkbox.htm
Regards,
Jeff
(if it's possible to add a checkbox to a datagrid)

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


Thanks for the input, I've added the button column to my datagrid, I
think the best result would be to launch a new page on the button
click, then passing the columns datafields to labels in the new page so
that they can be printed, will a button_click event handler be required
or can a new page be launched from using the selecteditem?

Apoligies for my lack of programming experience but I am an
Administrator by trade!.

Nov 19 '05 #4
"Mattyw" wrote:
Thanks for the input, I've added the button column to my datagrid, I
think the best result would be to launch a new page on the button
click, then passing the columns datafields to labels in the new page so
that they can be printed, will a button_click event handler be required
or can a new page be launched from using the selecteditem?

Apoligies for my lack of programming experience but I am an
Administrator by trade!.


Hi, the ASPNET quickstart at http://www.asp.net/Tutorials/quickstart.aspx
will show u how to do this, look under Web Form Controls Reference and the
DataGrid section. Specifically the VB DataGrid3.aspx example.

HTH
Nov 19 '05 #5

idi_amin wrote:
"Mattyw" wrote:
Thanks for the input, I've added the button column to my datagrid, I think the best result would be to launch a new page on the button
click, then passing the columns datafields to labels in the new page so that they can be printed, will a button_click event handler be required or can a new page be launched from using the selecteditem?

Apoligies for my lack of programming experience but I am an
Administrator by trade!.
Hi, the ASPNET quickstart at

http://www.asp.net/Tutorials/quickstart.aspx will show u how to do this, look under Web Form Controls Reference and the DataGrid section. Specifically the VB DataGrid3.aspx example.

HTH


That was exactly what I was looking for, all working fine now, thanks
for the
help everyone.

Nov 19 '05 #6

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

Similar topics

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...
0
by: Marco Martin | last post by:
Hi all, I need to figure the best solution to my problem. <Background> A Bill of materials application that has a treeview as the master and a datagrid as the details. The treeview holds...
1
by: adiel | last post by:
Hello everyone. The problem is when printing, the text gets cut half way and prints the other half on to the next page when printing using internet explorer and an asp.net datagrid. I am sure...
2
by: Allen Davis | last post by:
I have some hierarchical data bound to a series of nested DataLists and DataGrids for which I'd like to be able to provide the end-user some targeted printing capabilities. By that I mean being...
3
by: Tina | last post by:
Is there any utility or tool or function to print the contents of a web datagrid in report form? If not, does the new 2.0 framework/vs.net have such a capability? Thanks, T
5
by: Jay | last post by:
I have been searching and searching and searching for a way to print a lengthy datagrid on multiple pages and persist the header. I also do not want the last datagrid row on the page to be cut off...
5
by: Just D. | last post by:
Who and how prints reports from the WebApplication? For example if I have some dataview and show the report on the DataGrid the DataGrid is long and scrollable. How can I print the report on 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...
2
by: steve-russell | last post by:
I have a simple database (one table) created with Access. I have a simple query and report in Access and it works great. I have recreated the program in Visual Studio (vb) but can not figure out...
0
it0ny
by: it0ny | last post by:
Hi guys, thanks I am fairly new to this forum so I hope I chose the right place to post this question. I try to make my program printout a deposit's report. I created a class to store the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

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.