470,591 Members | 1,540 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,591 developers. It's quick & easy.

add "spacers to gridview"

How can I add a empty row to my gridview?

example:
column 1 column2
row 1
row2
row3
row4
empty row across the grid
row5
row6
row7
row8
empty row across the grid

and so on
Oct 16 '06 #1
3 3144
you need to get the info from whatever you are getting (DB 4 example)
and add into a datatable
then bind the datatable to the gridview

....
dr = command.executeReader()
while dr.read()
iRows += 1

r = dt.newRow()
r("column1") = dr.item("myColumn").toString
...
dt.rows.add(r)

if iRows mod 4 = 0 then
r = dt.newRow()
dt.Rows.Add(r)
end if

end while

....

gridView.DataSource = dt
gridView.DataBind()

that example will add an empty row to the Datatable each 4 rows

--

Bruno Alexandre
KÝbenhavn, Danmark

"a Portuguese in Denmark"

Blog. http://balexandre.blogspot.com/
Photos. http://www.flickr.com/photos/balexandre/
"igotyourdotnet" <ig************@nospam.nospamwrote in message
news:58**********************************@microsof t.com...
How can I add a empty row to my gridview?

example:
column 1 column2
row 1
row2
row3
row4
empty row across the grid
row5
row6
row7
row8
empty row across the grid

and so on

Oct 16 '06 #2
You can use the databinding event to alter rows. You should be able to add
rows, as well, at this step. Using Mod 4, you will have one after every
four.

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

*************************************************
Think outside of the box!
*************************************************
"igotyourdotnet" <ig************@nospam.nospamwrote in message
news:58**********************************@microsof t.com...
How can I add a empty row to my gridview?

example:
column 1 column2
row 1
row2
row3
row4
empty row across the grid
row5
row6
row7
row8
empty row across the grid

and so on

Oct 16 '06 #3
I can think about something like this:

Replace the gridview with a repeater
Make an item template that will include 2 table rows.
Databind the cells in the first row to the fields for column1 and column2.
Live the cells in the second row empty and make the second row hidden.
Handle the repeater's PreRender event. Loop through the repeater items and
show the second row in every 5th item.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
"igotyourdotnet" <ig************@nospam.nospamwrote in message
news:58**********************************@microsof t.com...
How can I add a empty row to my gridview?

example:
column 1 column2
row 1
row2
row3
row4
empty row across the grid
row5
row6
row7
row8
empty row across the grid

and so on

Oct 16 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Mark Richards | last post: by
10 posts views Thread by NH | last post: by
reply views Thread by hhoang.nl | last post: by
reply views Thread by Dave | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.