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

datagrid sort and headers on every page

sam
Hello Group,
Havent had luck posting it to
microsoft.public.dotnet.framework.aspnet.datagridc ontrol group. Excuse
me for the cross posting.
I have a datagrid which needs to be split into multiple
pages when printing along with headers on every page. I came up with
this routine below which adds 2 rows - one with datagrid headers and
the other is also a headers which consists other related information.
The 2 rows(headers) needs to be inserted for every
iMaxLines(constant-say 40) lines. When I debug, the headers get
inserted at correct positions but when doing a databind to
the datagrid(dgWIP), the headers show up at the very top of the
datagrid.
Not quite sure how to insert the headers and still retain
the sortorder. The initial databind is done as the addheaderlines
function is called after a postback and I need to retain the
sortorder. The sort is
disabled after the intial databind. Still cant understand, why are the
2 inserted rows shifted to the top of
the datagrid.
Any help on this issue would be great!!
cODE:

Private Sub addHeaderLines(ByVal dt As DataTable, ByVal part As
Int16)

Dim drHeader, drBlank As DataRow
Dim count, repeatCount, upperBound As Integer
Dim dvWIP As DataView

dvWIP = dt.DefaultView

dgWIP.DataSource = dvWIP
dvWIP.Sort = Me.SortColumn & " " & Me.SortOrder
dgWIP.DataBind()
dgWIP.AllowSorting = False
repeatCount = iMaxLines
upperBound = dt.Rows.Count

count = 0
While count <= upperBound

' If count Mod iMaxLines = 1 And count > 1 Then
If repeatCount = 1 Then
drBlank = dt.NewRow
drHeader = dt.NewRow
If part = 3 Then
drBlank(2) = "hd1"
drHeader(2) = "hd2"
Else
drBlank(0) = "hd1"
drHeader(0) = "hd2"
End If
dt.Rows.InsertAt(drBlank, count)
dt.Rows.InsertAt(drHeader, count + 1)
'count += 1
upperBound += 2
repeatCount = iMaxLines

Else

repeatCount -= 1

End If

count += 1

End While
dgWIP.DataSource = dt ' headers get shifted here...
dgWIP.DataBind()
End Sub

Thanks a bunch,
Sam.
Nov 22 '05 #1
3 2027
Sam,

What you are doing is not crossposting however multiposting, it had been
crossposting when you had send this message to more newsgroups in one time,
wherefore can be a good reason and mostly when not used wrong does not give
any complain.

Multiposting is more messages to more newsgroups, what mean when somebody
sees that and has searched for a solution for you can make im angry.

However your problem.

Did you already look at custompaging the datagrid, that is made for your
question in my opinion and very nice

http://msdn.microsoft.com/library/de...agingtopic.asp

I hope this helps?

Cor
Nov 22 '05 #2
sam
Cor,
Thanks for your reply. I guess you have misinterpreted my scenario.
CustomPaging is not what I am looking for. I do not use paging in the
datagrid and display all the rows in the same page. But when one needs
to print the page, I have a link "print version" which would have to
split the datagrid into multiple pages(according to the page size say
40 rows in one page) with headers prepended on each page. Hope, this
makes my case better if not clear.

Thanks,
Sam.

"Cor Ligthert" <no**********@planet.nl> wrote in message news:<#n*************@TK2MSFTNGP12.phx.gbl>...
Sam,

What you are doing is not crossposting however multiposting, it had been
crossposting when you had send this message to more newsgroups in one time,
wherefore can be a good reason and mostly when not used wrong does not give
any complain.

Multiposting is more messages to more newsgroups, what mean when somebody
sees that and has searched for a solution for you can make im angry.

However your problem.

Did you already look at custompaging the datagrid, that is made for your
question in my opinion and very nice

http://msdn.microsoft.com/library/de...agingtopic.asp

I hope this helps?

Cor

Nov 22 '05 #3
Hi Sam,

Trying to get it clear for me as well.
I assume now that you want to make in one time more sorted datatables that
you can use as the datasources for your datagrid. While the first row
contains header information and the rest normal. Problem for me with this is
that the datatable than has to contain all string columns what you probably
do not have.

What is probably more easier, is adding a column to your datatable, fill
that by going in a for index loop through it, and than use the dataview
again, where you can set a rowfilter accoording to the page height.

Before you go looking for that, you cannot add that column and using an
expression to fill the numbers and either you can not use the columnseed to
add that number.

When you need some code tell it than, for the first there should of course
the condition I wrote be fullfiled.

For the next time, a more proper newsgroup for this is in my opinion
microsoft.public.dotnet.framework.adonet,
because the datatable and dataview are parts of ADONET).

I hope this helps?

Cor

Nov 22 '05 #4

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

Similar topics

3
by: sam | last post by:
Hello Group, Havent had luck posting it to microsoft.public.dotnet.framework.aspnet.datagridcontrol group. Excuse me for the cross posting. I have a datagrid which needs to be split into multiple...
5
by: BlueFox | last post by:
Hi : When i display the DataBase in System.Windows.Forms. DataGrid ,i want to display the line number of ever line .How can i do it ? Any help may be Good .
2
by: Ken Tucker | last post by:
I've read about this issue in many articles across the net... But haven't found a solution. I see all kinds of custom code to perform sorting with datagrids, but my example is so simple, I must...
2
by: enak | last post by:
I can not get my datagrid to page. I have a datagrid that I can sort 2 of the columns. This works great. I added paging and when I display the dg it shows 5 pages. (I am showing page numbers at...
3
by: NoSf3RaTu | last post by:
Is there a way to only print out the datagrid in a given web page? That is I have a datagrid on my web page but I would like to add a button that will only give me a page with the datagrid to print...
0
by: Chris | last post by:
Ok, I think this is an easy one - I've just been staring at it too long. I'm creating a datagrid in asp.net/c# from scratch, i.e. nothing at all in the aspx page. I'm also creating all the...
11
by: rkbnair | last post by:
I have created a datagrid in my aspx with the 'AllowSorting' property to true. When clicking on the column header, the page refreshes. However the sorting is not done. Am I missing anything? I...
2
by: saleek | last post by:
Hi, I am trying to figure out why my datagrid has stopped firing the page and sort commands. Scenario: I originally had template columns in my datagrid and had set up custom bi-directional...
2
by: Joey | last post by:
I have an asp.net 1.1 C# web application with a datagrid. I set the datagrid's "AllowSorting" property to "True". Then I created a sort function for it by selecting the datagrid in the designer,...
0
by: rn5a | last post by:
A DataGrid control displays records from a SQL Server 2005 DB table. The AllowSorting property of the DataGrid has been set to True & the SortExpressions of the BoundColumns have been set to the...
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
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: 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
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.