473,396 Members | 2,011 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,396 software developers and data experts.

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 3550
On Oct 29, 2:20*pm, Ralf <marty.overd...@intergraph.comwrote:
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....col2....col3
.....col1....col2....col3
.....col1....col2....col3
Category 2
.....col1....col2....col3
.....col1....col2....col3
.....col1....col2....col3

This is done by using Repeater with a nested GridView:

<asp:Repeater ID="Repeater1" runat="server"
OnItemDataBound="Repeater1_ItemDataBound">
<ItemTemplate>
<div>
<asp:Label ID="lblCategoryName" runat="server" Text='<%#
Eval("BrochureCategoryName") %>' />
</div>
<div>

<asp:GridView ID="GridView1" runat="server" DataKeyNames="BrochureId">
<Columns>
<asp:TemplateField>
<ItemTemplate>

....

</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>

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

A code to populate GridView could be as a following

private void BindData()
{

DataSet ds = (DataSet)db.ExecuteDataSet(string.Format(
@"SELECT * FROM BrochureCategory;
SELECT b.* FROM Brochure b, BrochureCategory c
WHERE b.BrochureCategoryId=c.BrochureCategoryId", _websiteId)
);

// Attach the relationship to the dataSet
ds.Relations.Add(new DataRelation("CategoriesRelation",
ds.Tables[0].Columns["BrochureCategoryId"],
ds.Tables[1].Columns["BrochureCategoryId"]));

Repeater1.DataSource = ds.Tables[0];
Repeater1.DataBind();

}

protected void Repeater1_ItemDataBound(object sender,
RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
ListItemType.AlternatingItem)
{
DataRowView drv = e.Item.DataItem as DataRowView;

GridView GridView1 = e.Item.FindControl("GridView1") as GridView;
GridView1.DataSource = drv.CreateChildView("CategoriesRelation");
GridView1.DataBind();
}
}

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....col2....col3
.....col1....col2....col3
.....col1....col2....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
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...
3
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....
1
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...
5
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...
3
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...
2
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...
18
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...
2
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...
0
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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,...

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.