473,609 Members | 1,888 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Getting DataGrid Header information

I am writing a method in a component that gets passed a 1.1 Datagrid. The
datagrid's columns were created at run time meaning it has no columns
collection.

How can I access Header and Footer data in the grid?

It's not in the grid.items collection - only rows there. there is no
grid.header or grid.footer.

--
Regards,
Gary Blakely
Oct 7 '06 #1
7 7445
No, but there is a header row and a footer row and you can query row type.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
http://gregorybeamer.spaces.live.com

*************** *************** *************** ****
Think outside of the box!
*************** *************** *************** ****
"GaryDean" <Ga******@newsg roups.nospamwro te in message
news:OJ******** ******@TK2MSFTN GP03.phx.gbl...
>I am writing a method in a component that gets passed a 1.1 Datagrid. The
datagrid's columns were created at run time meaning it has no columns
collection.

How can I access Header and Footer data in the grid?

It's not in the grid.items collection - only rows there. there is no
grid.header or grid.footer.

--
Regards,
Gary Blakely


Oct 8 '06 #2
Hi Gary,

C#
MyGrid.Controls[0].Controls[0] ' header
MyGrid.Controls[0].Controls[MyGrid.Controls[0].Controls.Count - 1] ' footer

Vb.Net
MyGrid.Controls (0).Controls(0) ' header
MyGrid.Controls (0).Controls(My Grid.Controls(0 ).Controls.Coun t - 1) ' footer

Remeber to check if the ShowHeader and ShowFooter properties are set to true
before running the above code (plus the range check if
(MyGrid.Control s[0].Count 0) ...

Hope this helps

--
Milosz Skalecki
MCP, MCAD
"GaryDean" wrote:
I am writing a method in a component that gets passed a 1.1 Datagrid. The
datagrid's columns were created at run time meaning it has no columns
collection.

How can I access Header and Footer data in the grid?

It's not in the grid.items collection - only rows there. there is no
grid.header or grid.footer.

--
Regards,
Gary Blakely
Oct 8 '06 #3
Yes. that does it. Thanks much!

--
Regards,
Gary Blakely
"Milosz Skalecki" <mi*****@REMOVE ITwp.plwrote in message
news:3E******** *************** ***********@mic rosoft.com...
Hi Gary,

C#
MyGrid.Controls[0].Controls[0] ' header
MyGrid.Controls[0].Controls[MyGrid.Controls[0].Controls.Count - 1] '
footer

Vb.Net
MyGrid.Controls (0).Controls(0) ' header
MyGrid.Controls (0).Controls(My Grid.Controls(0 ).Controls.Coun t - 1) '
footer

Remeber to check if the ShowHeader and ShowFooter properties are set to
true
before running the above code (plus the range check if
(MyGrid.Control s[0].Count 0) ...

Hope this helps

--
Milosz Skalecki
MCP, MCAD
"GaryDean" wrote:
>I am writing a method in a component that gets passed a 1.1 Datagrid.
The
datagrid's columns were created at run time meaning it has no columns
collection.

How can I access Header and Footer data in the grid?

It's not in the grid.items collection - only rows there. there is no
grid.header or grid.footer.

--
Regards,
Gary Blakely

Oct 9 '06 #4
Hi Gary,

Milosz's suggestion is directly access the DataGrid's Controls collection
to retrieve the Header and Footer child control, this does work though it
require us to have clear view of the DataGrid's control tree (you can view
page's control tree by turn on the page's output trace). However, I would
still recommend that we avoid this as much as possible since accessing
child control through index only is dangerous which may break between
different version changes.

BTW, are you using the DataGrid in ASP.NET 1.1 application or ASP.NET 2.0
application. If you're using it in ASP.NET 2.0 or plan to upgrade the
application to ASP.NET 2.0, you can consider the GridView control(specifi c
to ASP.NET 2.0) since it has naturally expose the "Footer" and "Header" as
two public properties (FooterRow and HeaderRow).

Please feel free to post here if you need any further help.
Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.

Oct 9 '06 #5
Steven,

I agree with you but my answer is based on his post (datagrid, asp.net 1.1,
reference is passed - so i quess you cannot do it in proper way i.e. in
itemcreated) :)

Regards
--
Milosz Skalecki
MCP, MCAD
"Steven Cheng[MSFT]" wrote:
Hi Gary,

Milosz's suggestion is directly access the DataGrid's Controls collection
to retrieve the Header and Footer child control, this does work though it
require us to have clear view of the DataGrid's control tree (you can view
page's control tree by turn on the page's output trace). However, I would
still recommend that we avoid this as much as possible since accessing
child control through index only is dangerous which may break between
different version changes.

BTW, are you using the DataGrid in ASP.NET 1.1 application or ASP.NET 2.0
application. If you're using it in ASP.NET 2.0 or plan to upgrade the
application to ASP.NET 2.0, you can consider the GridView control(specifi c
to ASP.NET 2.0) since it has naturally expose the "Footer" and "Header" as
two public properties (FooterRow and HeaderRow).

Please feel free to post here if you need any further help.
Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.

Oct 9 '06 #6
Hi Steven,
A couple years ago I wrote a component called PrintGrid
(http://www.deanblakely.com/PrintGrid.aspx). The component creates a
Crystal Report of any DataGrid. It worked for the 1.1 DataGrid but I wrote
it using the Columns collection (my mistake) so it would not work for
columns created at run time. I have given it away to several hunderd
developers that are probably still using it.

Now I am improving the component by (1) converting it so it will work for
columns created at run time for the DataGrid and (2) work for the new 2.0
GridView. All the developer has to do is call a method in my component,
passing either a DataGrid or a GridView object to print a report.

So, I understand that you are suggesting that using the controls collection
may not be a safe thing to do. Ok, but what is my alternative? How can I
get the Header and Footer text without using the Columns Collection and
without using the Controls Collection for the 1.1 DataGrid?

Later, when I'm working on the GridView it looks like it will be easier
since there are the two properties you mention. But, PrintGrid must provide
functionality for the 1.1 DataGrid for a long time because it will be used
for a long time.
--
Regards,
Gary Blakely
"Steven Cheng[MSFT]" <st*****@online .microsoft.comw rote in message
news:bf******** ******@TK2MSFTN GXA01.phx.gbl.. .
Hi Gary,

Milosz's suggestion is directly access the DataGrid's Controls collection
to retrieve the Header and Footer child control, this does work though it
require us to have clear view of the DataGrid's control tree (you can
view
page's control tree by turn on the page's output trace). However, I would
still recommend that we avoid this as much as possible since accessing
child control through index only is dangerous which may break between
different version changes.

BTW, are you using the DataGrid in ASP.NET 1.1 application or ASP.NET 2.0
application. If you're using it in ASP.NET 2.0 or plan to upgrade the
application to ASP.NET 2.0, you can consider the GridView control(specifi c
to ASP.NET 2.0) since it has naturally expose the "Footer" and "Header" as
two public properties (FooterRow and HeaderRow).

Please feel free to post here if you need any further help.
Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no
rights.

Oct 9 '06 #7
Thanks for your followup Gary,

So I've got the point here that your helper method will accept both 1.1
DataGrid and 2.0 Gridview class instance. Thus, I agree that except
directly access the Controls collection, there is no other means to get
the header and footer control collection for 1.1 DataGrid.

Anyway, I still suggest you add more protection code (like check null
reference) in your code which access Header/Footer through index in
Controls collection.

Please feel free to let me know if there is anything else we can help.
Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.

Oct 10 '06 #8

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

Similar topics

1
3495
by: | last post by:
How I can autosize a DataGrid after then associate a Datasource=Dataset in Smart Devices applications or Windows forms application?? That same?? -- Cumprimentos, David de Passos -------------------------------------------------------------- RCSOFT, Lda.
2
945
by: DelphiBlue | last post by:
I have a Nested Datagrid that is using a data relations to tie the parent child datagrids together. All is working well with the display but I am having some issues trying to sort the child datagrid. HTML Datagrid1 TemplateColumn Table Header information Detail Information
0
1303
by: amber | last post by:
Okay, there is some wierdness going on with my datagrid... I'm trying to make my column header 2 lines high. If I go into the Form - InitializeComponent code, and change the line: Me.DataGridTextBoxColumn9.HeaderText = "Percentage" TO Me.DataGridTextBoxColumn9.HeaderText = "Percentage" & vbCrLf & "(%)" and then run my program, everything works great - the datagrid displays the
2
2493
by: Josef Meile | last post by:
Hi, I'm using a ComboBox, some Textboxes, and a DataGrid to represent a many-to-many relationship between Person and Course. Each time that I change the value in the ComboBox (which for now is the OID of Person), the information of the person matching the selected OID is shown in the Textboxes (Name, Address, id, etc) and the courses this person is taken are shown in a DataGrid (course name, price, etc.). This is working well so far, I...
1
1195
by: David Lozzi | last post by:
Hi, I'd like to customize a header in a DataGrid. I want to add a link in the header, as well as pull a recordset's ID. I am using a TemplateColumn so that I can hold several lines of information in one column. The header is now called General Information, I'd like to add an Edit, linked to another page referencing the selected record's ID from a request. And because it is a templatecolumn, I cannot use the built-in edit with DataGrid. ...
3
1565
by: AMD Desktop | last post by:
Hi, I need to add a header to a datagrid. This is the code I am trying to use: Dim dgStaffingReport As New DataGrid Dim dgitem As New DataGridItem(0, 0, ListItemType.Header) Dim mycell As New TableCell()
0
1824
by: Daniel Doyle | last post by:
Hello and apologies in advance for the amount of code in this post. I've also sent this message to the Sharepoint group, but thought that ASP.NET developers may also be able to help, even though it's a Sharepoint WebPart. I'm trying to do something fairly simple, create a datagrid that displays where and when a person works and allows them to change some of the information via DropDownLists. When the user clicks to edit a row, three of...
2
8587
by: Santosh | last post by:
Dear all i want to bind data to datagrid header template i am wrtting follwing code it is displaying data with in item template not but it is display data in header template <asp:DataGrid ID="datagrid" Runat="server" ShowHeader="True"> <Columns> <asp:TemplateColumn> <HeaderTemplate> <asp:Label ID="Label1" Runat="server" Text='<%#
2
6579
by: =?Utf-8?B?Y3JlYXZlczA2MjI=?= | last post by:
I have a nested datagrid in a xaml file, the parent datagrid loads the vendor information and the details loads the documents for that vendor in a datagrid. Everything is working fine until I click in the child datagrid and then go to the combobox and choose another vendor. When the new vendor is loaded nothing shows in the datagrid but the itemsource shows the info is there. Know if I click on the child cell and then click back on the...
0
8091
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
8579
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8555
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8232
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8408
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...
1
6064
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5524
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();...
1
1686
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1403
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.