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

Getting error adding an extra header to datagrid

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()

mycell.ColumnSpan = 2
mycell.Text = "Staff"
dgitem.Cells.Add(mycell)
dgStaffingReport.Controls(0).Controls.AddAt(0, dgitem)

And this is the error I am getting (index of the AddAt method, pretty
standard...):
Exception Details: System.ArgumentOutOfRangeException: Specified argument
was out of the range of valid values. Parameter name: index

Source Error:

Line 175: mycell.Text = "This Is the top level header item spanning two
columns!"
Line 176: dgitem.Cells.Add(mycell)
Line 177: dgStaffingReport.Controls(0).Controls.AddAt(0, dgitem)
Line 178:
Line 179:

Any idea why. Can anyone help?

Thank you
Nov 18 '05 #1
3 1551
The datagrid doesn't support adding another header.
However, you can fake it with the techniques outlined here:
http://devcenter.infragistics.com/Ar...ArticleID=1229

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"AMD Desktop" <ma******@yahoo.com> wrote in message
news:JN********************@magma.ca...
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()

mycell.ColumnSpan = 2
mycell.Text = "Staff"
dgitem.Cells.Add(mycell)
dgStaffingReport.Controls(0).Controls.AddAt(0, dgitem)

And this is the error I am getting (index of the AddAt method, pretty
standard...):
Exception Details: System.ArgumentOutOfRangeException: Specified argument
was out of the range of valid values. Parameter name: index

Source Error:

Line 175: mycell.Text = "This Is the top level header item spanning two
columns!"
Line 176: dgitem.Cells.Add(mycell)
Line 177: dgStaffingReport.Controls(0).Controls.AddAt(0, dgitem)
Line 178:
Line 179:

Any idea why. Can anyone help?

Thank you

Nov 18 '05 #2
Is there any way to add a header? I can not use this method because this
datagrid is not for display, I export it into excel.

:-(
"Steve C. Orr [MVP, MCSD]" <St***@Orr.net> wrote in message
news:Op**************@TK2MSFTNGP11.phx.gbl...
The datagrid doesn't support adding another header.
However, you can fake it with the techniques outlined here:
http://devcenter.infragistics.com/Ar...ArticleID=1229
--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"AMD Desktop" <ma******@yahoo.com> wrote in message
news:JN********************@magma.ca...
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()

mycell.ColumnSpan = 2
mycell.Text = "Staff"
dgitem.Cells.Add(mycell)
dgStaffingReport.Controls(0).Controls.AddAt(0, dgitem)

And this is the error I am getting (index of the AddAt method, pretty
standard...):
Exception Details: System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. Parameter name: index

Source Error:

Line 175: mycell.Text = "This Is the top level header item spanning two
columns!"
Line 176: dgitem.Cells.Add(mycell)
Line 177: dgStaffingReport.Controls(0).Controls.AddAt(0, dgitem)
Line 178:
Line 179:

Any idea why. Can anyone help?

Thank you


Nov 18 '05 #3
The datagrid does not support it.
You might look into using the table control instead. It doesn't have as
much functionality, but it also doesn't have as many limitations.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"AMD Desktop" <ma******@yahoo.com> wrote in message
news:__********************@magma.ca...
Is there any way to add a header? I can not use this method because this
datagrid is not for display, I export it into excel.

:-(
"Steve C. Orr [MVP, MCSD]" <St***@Orr.net> wrote in message
news:Op**************@TK2MSFTNGP11.phx.gbl...
The datagrid doesn't support adding another header.
However, you can fake it with the techniques outlined here:

http://devcenter.infragistics.com/Ar...ArticleID=1229

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"AMD Desktop" <ma******@yahoo.com> wrote in message
news:JN********************@magma.ca...
> 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()
>
> mycell.ColumnSpan = 2
> mycell.Text = "Staff"
> dgitem.Cells.Add(mycell)
> dgStaffingReport.Controls(0).Controls.AddAt(0, dgitem)
>
> And this is the error I am getting (index of the AddAt method, pretty
> standard...):
>
>
> Exception Details: System.ArgumentOutOfRangeException: Specified argument > was out of the range of valid values. Parameter name: index
>
> Source Error:
>
> Line 175: mycell.Text = "This Is the top level header item spanning two
> columns!"
> Line 176: dgitem.Cells.Add(mycell)
> Line 177: dgStaffingReport.Controls(0).Controls.AddAt(0, dgitem)
> Line 178:
> Line 179:
>
>
>
> Any idea why. Can anyone help?
>
> Thank you
>
>



Nov 18 '05 #4

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

Similar topics

1
by: Wayno | last post by:
My php logs are coming up empty. I have done all I can think of, and all that made sense to me. Can someone take a look at my php.ini please and tell me what you think may be the problem. I...
0
by: Brian Greiwe | last post by:
I posted this in the datagrid forum but got no bites, so I thought I'd post it here as well for some help.... I've created a datagrid with 1 edititemtemplate column. When the user clicks...
6
by: Peter Frost | last post by:
Please help I don't know if this is possible but what I would really like to do is to use On Error Goto to capture the code that is being executed when an error occurs. Any help would be much...
2
by: Clayton Hamilton | last post by:
I have a DataGrid on a webform bound to a Datasource and can successfully use <ItemTemplate> to create edit/update/cancel functionality for user maintenance of data. I use separate logic to delete...
0
by: pei_world | last post by:
I am using the following code to configurate my datagrid and load data from my Pocket Access Database. however, I got some more row extra, and it is the number I setted with my object array in my...
3
by: DigHazuse | last post by:
relative noob. i'm trying to get/display the column Header name that the user clicks to sort on the DataGrid. I know that i could take the e.SortExpression and spin through the Columns on the...
0
by: Jim Heavey | last post by:
Hello, I am trying to figure out how to add an extra row of heading to my datagrid. I came up with the following code: Public Sub dgNewMovies_ItemCreated(ByVal sender As Object, ByVal e As...
0
by: Tim::.. | last post by:
I keep getting the following error on a dropdownlist control I have added to a datagrid! I have given the control the correct id and don't get any errors when conpiling the code but as soon as I try...
1
by: Gunjan Garg | last post by:
Hello All, I am working to create a generic datagrid which accepts a datasource(ListData - This is our own datatype) and depending on the calling program customizes itself for sorting,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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
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,...

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.