gridview formatting

J

John

On my gridview I need to group the sales by year.
2000 - 2001 - 2002, etc is there a way to do this with using the gridview?

example:
sales for: 2000
data
blank row
sales for: 2001
data
blank row

now the data that is being pulled back to populate the grid is the year
 
B

Bruno Alexandre

of course you can...

<asp:GridView id="gv2003" ...
<br />
<asp:GridView id="gv2002" ...
<br />
<asp:GridView id="gv2001" ...
<br />
<asp:GridView id="gv2000" ...


and populate each grid view with the data you want, you could even have a
function that returns a datatable and in page_load statmente you should
write something like:

gv2003.DataSource = loadData("2003")
gv2003.DataBind()
gv2002.DataSource = loadData("2002")
gv2002.DataBind()
gv2001.DataSource = loadData("2001")
gv2001.DataBind()
gv2000.DataSource = loadData("2000")
gv2000.DataBind()


because to add a blank row to your GV you need to use OnRowCreate statement
from the GV, and then you need to separate the data from years, it could
give you more work than the simple I showed you above...

....if you have a problem about time consuming, because you are getting
values from the DB 4 times, you could do that once and populate a datatable
and then using DataTable filtering you can sort the data through the 4
individual GV's
 
J

John

ah, no. I'm not having anywhere from 1 to 20 grids on my page.
could this be done easier using a datagrid instead of the gridview?
 
B

Bruno Alexandre

GridView is way better than DataGrid... just remember that GridView is the
2nd version of the DataGrid in .NET 1.x

you could still do the same as I mencionated, use the GV_RowCreate and
separate your data.
 
J

John

how would I seperate the data though? I'm getting the year back in the
dataset thats populating the grid. So how can i read that row/column that
has the year and break it apart and show the data pertaining to that year?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,817
Latest member
DicWeils

Latest Threads

Top