473,811 Members | 3,151 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Printing Gridview with LOTS of columns

I have a custome request to print a gridview with lots of columns, 31
to be exact. I know how to print out a gridview, done it already for
a GV with 6 columns. But, this GV is very wide and will not fit on a
page. I looked into using a repeater, but couldn't figure it out.
Tried datalists, no luck.
Does anybody have an idea of how I can output the data where it will
print. It doesn't have to output into a gridview, I just need it
printable...
Oct 29 '08 #1
2 3573
On Oct 29, 2:20*pm, Ralf <marty.overd... @intergraph.com wrote:
I have a custome request to print a gridview with lots of columns, 31
to be exact. *I know how to print out a gridview, done it already for
a GV with 6 columns. *But, this GV is very wide and will not fit on a
page. *I looked into using a repeater, but couldn't figure it out.
Tried datalists, no luck.
Does anybody have an idea of how I can output the data where it will
print. *It doesn't have to output into a gridview, I just need it
printable...
Ralf, using Repeater with a nested GridView is quite easy. Here's an
example I used to show list of brochures by categories. The result
list looks in the following way:

Category1
.....col1....co l2....col3
.....col1....co l2....col3
.....col1....co l2....col3
Category 2
.....col1....co l2....col3
.....col1....co l2....col3
.....col1....co l2....col3

This is done by using Repeater with a nested GridView:

<asp:Repeater ID="Repeater1" runat="server"
OnItemDataBound ="Repeater1_Ite mDataBound">
<ItemTemplate >
<div>
<asp:Label ID="lblCategory Name" runat="server" Text='<%#
Eval("BrochureC ategoryName") %>' />
</div>
<div>

<asp:GridView ID="GridView1" runat="server" DataKeyNames="B rochureId">
<Columns>
<asp:TemplateFi eld>
<ItemTemplate >

....

</ItemTemplate>
</asp:TemplateFie ld>
</Columns>
</asp:GridView>

</div>
</ItemTemplate>
</asp:Repeater>

A code to populate GridView could be as a following

private void BindData()
{

DataSet ds = (DataSet)db.Exe cuteDataSet(str ing.Format(
@"SELECT * FROM BrochureCategor y;
SELECT b.* FROM Brochure b, BrochureCategor y c
WHERE b.BrochureCateg oryId=c.Brochur eCategoryId", _websiteId)
);

// Attach the relationship to the dataSet
ds.Relations.Ad d(new DataRelation("C ategoriesRelati on",
ds.Tables[0].Columns["BrochureCatego ryId"],
ds.Tables[1].Columns["BrochureCatego ryId"]));

Repeater1.DataS ource = ds.Tables[0];
Repeater1.DataB ind();

}

protected void Repeater1_ItemD ataBound(object sender,
RepeaterItemEve ntArgs e)
{
if (e.Item.ItemTyp e == ListItemType.It em || e.Item.ItemType ==
ListItemType.Al ternatingItem)
{
DataRowView drv = e.Item.DataItem as DataRowView;

GridView GridView1 = e.Item.FindCont rol("GridView1" ) as GridView;
GridView1.DataS ource = drv.CreateChild View("Categorie sRelation");
GridView1.DataB ind();
}
}

When you have many colums you have to find how you could rearrange the
view. Maybe you can follow my example and show one or more "main"
columns as a Repeater data rows and the rest could be nested using a
GridView control.

Category1 Name1 Name2
Description.... ..
.....col1....co l2....col3
.....col1....co l2....col3
.....col1....co l2....col3

or

Category1 Name1 Name2
Description.... ..
.....col1=val1
.....col2=val2
.....col3=val3
.....col4=val4
.....col5=val5
Oct 29 '08 #2
>
Category1 Name1 Name2
Description.... ..
....col1=val1
....col2=val2
....col3=val3
....col4=val4
....col5=val5
This is a possiblity of doing it this way. I would list the row
identifier in at the Top, and then have the col1=val like you have it
to show all the data. It doesn't matter if it runs multiple pages for
each row. I will give this a try, probably tomorrow and post my
results. Thx

Oct 29 '08 #3

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

Similar topics

5
2165
by: Mr. B | last post by:
This is driving me NUTZ!!! I've been screwing around on this for a week now. And I have tried to find examples similar to what I have (nada). Got lots of streaming a TXT file... bah! I am really stuck here (probably the ol' Not seeing the tree cause of the forest thingy). But I just can not get this to work. The following is my Test example code. Just needs a Button1 on a blank Form. Add in PrintDocument1, PrintPreviewDialog1,...
3
13759
by: NateDawg | last post by:
I'm reposting this. I'm kinda in a bind untill i get this figured out, so if anyone has some input it would sure help me out. Ok, I’ve noticed a few gridview problems floating around the forum. Everyone wants to do a java confirmation box when a user clicks the delete button. Fair enough, basic user design rules state that you should always confirm a delete action. There is also a consensus that the best way to do this is a template...
1
2814
by: =?Utf-8?B?SGFycnkgS2Vjaw==?= | last post by:
I have a GridView that I dynamically add columns to in code. The way that my code is written, everything works properly if I use GridView.Columns.Add to simply add the columns to the end of the collection. However, if I use GridView.Columns.Insert to inject the columns in the middle of the existing columns, I see lots of exceptions when I page the GridView, because certain controls contained within the grid are mysteriously absent? Can...
5
54723
by: mohaaron | last post by:
OK, I have now gone through lots of posts, and there are lots, looking for a anwer as to why I can't set the width of the columns in my gridview. So far I have tried the following methods to set the width and nothing works. 1. <asp:BoundField HeaderText="fieldName" ItemStyle-Width="300px" DataField="fieldName" /> 2. <asp:BoundField HeaderText="fieldName" HeaderStyle-Width="300px" DataField="fieldName" /> 3. This has been tried in both...
3
1939
by: Nathan Sokalski | last post by:
I have a GridView control with three columns, all BoundField columns. They all have a HeaderText and DataField property set, and the third one has a DataFormatString property as well. When I run my code, the GridView displays two sets of columns. The first set looks exactly as I would expect. The second set, which should not be there anyway, uses the DataField as the header and does not apply the DataFormatString for the third column. What...
2
2834
by: GISmatters | last post by:
I have unbound checkboxes in a nested gridview to allow multi-selection of "child" rows. For context, the parent gridview rows are for large "reports", the child rows are for various specific files comprising each report. I want the user to be able to select an arbitrary collection of report files and have them emailed by clicking an "Email selected files" button. Everything displays properly, including the checkboxes for each child row (each...
18
11322
by: Brett | last post by:
I have an ASP.NET page that displays work orders in a GridView. In that GridView is a checkbox column. When the user clicks a "Print" button, I create a report, using the .NET Framework printing classes, for each of the checked rows in the GridView. This works fine in the Visual Studio 2005 development environment on localhost. But, when I move the page to the web server, I get the error "Settings to access printer...
2
4020
by: Andez | last post by:
All, I've got a GridView in a scrollable panel (in ASP.NET 2.0), which when printed will remove the scrolling part and expand to fit the whole GridView in which is OK - prints fine. I've also got a chart on the page that will graphically represent the data. All printing is ok, except when I retrieve large volumes of data. However, when I retrieve lots of data, the GridView does not fit on the page (either Portrait/Landscape). Whats...
0
1886
by: cmrhema | last post by:
Hi, I have a gridview problem while binding more than two gridviews. I am giving a sample scenario of what I have done so far I have two tables First table: Department , having columns DeptId and DeptName
0
9607
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10137
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9211
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6895
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5564
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5700
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4352
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3876
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3027
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.