Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Headings in the DataGrid Web Control

Reply
Thread Tools

Headings in the DataGrid Web Control

 
 
=?Utf-8?B?QWxhbiBMYW1iZXJ0?=
Guest
Posts: n/a
 
      09-29-2004
I am writing a web-based reporting tool and using a datagrid to display
information returned from a database.

I am displaying column headings from bound columns with no problems but I
need to have a heading above some of these that spans severla columns e.g.

--------- OverAll Heading ---------
Heading1 Heading2 Heading3

I can't find a way to do this. Is this possible and, if so, how?

Any help you can give would be very appreciated.

Many thanks.

Alan
 
Reply With Quote
 
 
 
 
Alvin Bruney [MVP]
Guest
Posts: n/a
 
      09-29-2004
have a look at the columnspan property of the cell, it makes the cell
stretch over the number of columns. you will need to remove the other cells
before or after you span. additionally you will need to promote row 1 to a
header. bit of code but not impossible

--
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
"Alan Lambert" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I am writing a web-based reporting tool and using a datagrid to display
> information returned from a database.
>
> I am displaying column headings from bound columns with no problems but I
> need to have a heading above some of these that spans severla columns e.g.
>
> --------- OverAll Heading ---------
> Heading1 Heading2 Heading3
>
> I can't find a way to do this. Is this possible and, if so, how?
>
> Any help you can give would be very appreciated.
>
> Many thanks.
>
> Alan



 
Reply With Quote
 
 
 
 
=?Utf-8?B?QWxhbiBMYW1iZXJ0?=
Guest
Posts: n/a
 
      09-29-2004
Thanks for the reply.

Doing the colspan should be no problem but I'm not sure what you mean when
you say promote row 1 to a header. Wouldn't row 1 contain the first record of
bound data? What would happen to the dat in this row? Or have I completely
misunderstood?


"Alvin Bruney [MVP]" wrote:

> have a look at the columnspan property of the cell, it makes the cell
> stretch over the number of columns. you will need to remove the other cells
> before or after you span. additionally you will need to promote row 1 to a
> header. bit of code but not impossible
>
> --
> Regards,
> Alvin Bruney
> [ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
> Got tidbits? Get it here... http://tinyurl.com/27cok
> "Alan Lambert" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> >I am writing a web-based reporting tool and using a datagrid to display
> > information returned from a database.
> >
> > I am displaying column headings from bound columns with no problems but I
> > need to have a heading above some of these that spans severla columns e.g.
> >
> > --------- OverAll Heading ---------
> > Heading1 Heading2 Heading3
> >
> > I can't find a way to do this. Is this possible and, if so, how?
> >
> > Any help you can give would be very appreciated.
> >
> > Many thanks.
> >
> > Alan

>
>
>

 
Reply With Quote
 
Alvin Bruney [MVP]
Guest
Posts: n/a
 
      09-29-2004
>> > --------- OverAll Heading ---------
>> > Heading1 Heading2 Heading3


according to your diagram, you have one header cell stretched across the
entire grid over Overall heading -----------. well that is the header cell.

you still need headers for each column(heading1, heading2, heading3). i was
suggesting one approach would be to insert an empty row at position 0 into
your dataset before binding. then you can customize row 0 on the
itemdatabound to be the actual column headers 1, 2, 3 etc

--
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
"Alan Lambert" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Thanks for the reply.
>
> Doing the colspan should be no problem but I'm not sure what you mean when
> you say promote row 1 to a header. Wouldn't row 1 contain the first record
> of
> bound data? What would happen to the dat in this row? Or have I completely
> misunderstood?
>
>
> "Alvin Bruney [MVP]" wrote:
>
>> have a look at the columnspan property of the cell, it makes the cell
>> stretch over the number of columns. you will need to remove the other
>> cells
>> before or after you span. additionally you will need to promote row 1 to
>> a
>> header. bit of code but not impossible
>>
>> --
>> Regards,
>> Alvin Bruney
>> [ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
>> Got tidbits? Get it here... http://tinyurl.com/27cok
>> "Alan Lambert" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>> >I am writing a web-based reporting tool and using a datagrid to display
>> > information returned from a database.
>> >
>> > I am displaying column headings from bound columns with no problems but
>> > I
>> > need to have a heading above some of these that spans severla columns
>> > e.g.
>> >
>> > --------- OverAll Heading ---------
>> > Heading1 Heading2 Heading3
>> >
>> > I can't find a way to do this. Is this possible and, if so, how?
>> >
>> > Any help you can give would be very appreciated.
>> >
>> > Many thanks.
>> >
>> > Alan

>>
>>
>>



 
Reply With Quote
 
Mark Rae
Guest
Posts: n/a
 
      09-30-2004
"Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
news:%23OJJd%(E-Mail Removed)...
> have a look at the columnspan property of the cell, it makes the cell
> stretch over the number of columns. you will need to remove the other
> cells before or after you span. additionally you will need to promote row
> 1 to a header. bit of code but not impossible


Related to this, is there any way to spread one row from the DataSet across
two rows in the DataGrid? E.g. if you were going through a data merging
exercise where you had legacy data in one table and current data in another
table and you wanted to compare the two? They will both have the same number
of columns and are joined by a primary key something like:

SELECT
l.FirstName, l.Surname, l.Address1, l.Town, l.County, l.Postcode,
c.FirstName, c.Surname, c.Address1, c.Town, c.County, c.Postcode
FROM EmployeeLegacy l, EmployeeCurrent c
WHERE l.EmployeeID = c.EmployeeID

Ignoring the fact that the above will give duplicate column names (it's just
an illustration), would it be possible to render it in the DataGrid so that
each row from the DataSet appeared as two rows in the DataGrid e.g.

Source FirstName Surname Address1 Town County Postcode
Legacy Mark Rae 1 High St London NULL SW1A 1AA
Current Mark T Rae 1 High S London NULL SW1A 1AA


 
Reply With Quote
 
=?Utf-8?B?QWxhbiBMYW1iZXJ0?=
Guest
Posts: n/a
 
      09-30-2004
Ah, now I get it!

Many thanks for the advice.

Alan

"Alvin Bruney [MVP]" wrote:

> >> > --------- OverAll Heading ---------
> >> > Heading1 Heading2 Heading3

>
> according to your diagram, you have one header cell stretched across the
> entire grid over Overall heading -----------. well that is the header cell.
>
> you still need headers for each column(heading1, heading2, heading3). i was
> suggesting one approach would be to insert an empty row at position 0 into
> your dataset before binding. then you can customize row 0 on the
> itemdatabound to be the actual column headers 1, 2, 3 etc
>
> --
> Regards,
> Alvin Bruney
> [ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
> Got tidbits? Get it here... http://tinyurl.com/27cok
> "Alan Lambert" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Thanks for the reply.
> >
> > Doing the colspan should be no problem but I'm not sure what you mean when
> > you say promote row 1 to a header. Wouldn't row 1 contain the first record
> > of
> > bound data? What would happen to the dat in this row? Or have I completely
> > misunderstood?
> >
> >
> > "Alvin Bruney [MVP]" wrote:
> >
> >> have a look at the columnspan property of the cell, it makes the cell
> >> stretch over the number of columns. you will need to remove the other
> >> cells
> >> before or after you span. additionally you will need to promote row 1 to
> >> a
> >> header. bit of code but not impossible
> >>
> >> --
> >> Regards,
> >> Alvin Bruney
> >> [ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
> >> Got tidbits? Get it here... http://tinyurl.com/27cok
> >> "Alan Lambert" <(E-Mail Removed)> wrote in message
> >> news:(E-Mail Removed)...
> >> >I am writing a web-based reporting tool and using a datagrid to display
> >> > information returned from a database.
> >> >
> >> > I am displaying column headings from bound columns with no problems but
> >> > I
> >> > need to have a heading above some of these that spans severla columns
> >> > e.g.
> >> >
> >> > --------- OverAll Heading ---------
> >> > Heading1 Heading2 Heading3
> >> >
> >> > I can't find a way to do this. Is this possible and, if so, how?
> >> >
> >> > Any help you can give would be very appreciated.
> >> >
> >> > Many thanks.
> >> >
> >> > Alan
> >>
> >>
> >>

>
>
>

 
Reply With Quote
 
Alvin Bruney [MVP]
Guest
Posts: n/a
 
      09-30-2004
one approach is to create a results dataset. then loop thru each row in
dataset1, find the appropriate information in dataset two and insert two
rows into the new results dataset. fill the rows as needed with information
from dataset1 and dataset2

roughly
DataSet dsTemp = new DataSet();

DataTable Tables = new DataTable();

dsTemp.Tables.Add(Tables);

for( int i = 0; i < dataset1.tables[0].rows.count; i++)
{
DataRow rowOne = dataset1.tables[0].rows.NewRow();

rowOne[0] = dataset1.tables[0].rows[i][0].tostring();
rowOne[1] = dataset2.tables[0].rows[i][1].tostring();
dsTemp.Tables[0].Rows.Add(rowOne);


DataRow rowTwo = dataset1.tables[0].rows.NewRow();
rowTwo[0] = dataset1.tables[0].rows[i][2].tostring();
rowTwo[1] = dataset2.tables[0].rows[i][3].tostring();
dsTemp.Tables[0].Rows.Add(rowTwo);

}

bind to grid using dsTemp

--
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
"Mark Rae" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> "Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
> news:%23OJJd%(E-Mail Removed)...
>> have a look at the columnspan property of the cell, it makes the cell
>> stretch over the number of columns. you will need to remove the other
>> cells before or after you span. additionally you will need to promote row
>> 1 to a header. bit of code but not impossible

>
> Related to this, is there any way to spread one row from the DataSet
> across two rows in the DataGrid? E.g. if you were going through a data
> merging exercise where you had legacy data in one table and current data
> in another table and you wanted to compare the two? They will both have
> the same number of columns and are joined by a primary key something like:
>
> SELECT
> l.FirstName, l.Surname, l.Address1, l.Town, l.County, l.Postcode,
> c.FirstName, c.Surname, c.Address1, c.Town, c.County, c.Postcode
> FROM EmployeeLegacy l, EmployeeCurrent c
> WHERE l.EmployeeID = c.EmployeeID
>
> Ignoring the fact that the above will give duplicate column names (it's
> just an illustration), would it be possible to render it in the DataGrid
> so that each row from the DataSet appeared as two rows in the DataGrid
> e.g.
>
> Source FirstName Surname Address1 Town County Postcode
> Legacy Mark Rae 1 High St London NULL SW1A
> 1AA
> Current Mark T Rae 1 High S London NULL SW1A
> 1AA
>



 
Reply With Quote
 
Mark Rae
Guest
Posts: n/a
 
      09-30-2004
"Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
news:%(E-Mail Removed)...

> one approach is to create a results dataset. then loop thru each row in
> dataset1, find the appropriate information in dataset two and insert two
> rows into the new results dataset. fill the rows as needed with
> information from dataset1 and dataset2


Thanks for the advice - I'll give it a go...


 
Reply With Quote
 
rosh
Guest
Posts: n/a
 
      10-06-2004


thnkx for the reply
as per the solution suggested by you I have added a blank row to the
dataset table before binding it to dataGrid but my requirement is that
the blank row must be the first row in the dataset coz this will help me
shifting my headers one row below(from row 0 to row 1)and thus i'll b
able to use my row 0 to span the 2 columns of my header field.
Note: i want the "Accounts" column to span my 4'th n 5'th column of the
header in data grid..
could you help me out with this....a code snippet will be an added
advantage for my solution.
thnkx

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
Reply With Quote
 
rosh
Guest
Posts: n/a
 
      10-06-2004

hi thnkx 4 reply
can u elaborate more on how do i promote row 1 to a
header?my header is having the sorting,hyperlink functionality....will i
not loose that if i try shifting header from row 0 to row 1?i am not
clear about it.could you pleaz explain it with the help of an example
code lines?
waiting for reply.....
cheers

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using labels within datagrid template headings John ASP .Net 2 04-10-2005 08:57 PM
Datagrid : massive headings when no data to display Bazza Formez ASP .Net 2 12-08-2004 11:23 PM
Headings in the DataGrid Web Control Alan Lambert ASP .Net Datagrid Control 7 09-30-2004 02:30 PM
Re: Datagrid headings Saravana ASP .Net 1 07-23-2003 01:39 PM
Sorting in a DataGrid with no headings Tracey ASP .Net 0 07-23-2003 12:37 PM



Advertisments