add "spacers to gridview"

Discussion in 'ASP .Net' started by =?Utf-8?B?aWdvdHlvdXJkb3RuZXQ=?=, Oct 16, 2006.

  1. 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
    =?Utf-8?B?aWdvdHlvdXJkb3RuZXQ=?=, Oct 16, 2006
    #1
    1. Advertising

  2. 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" <> wrote in message
    news:...
    > 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
    Bruno Alexandre, Oct 16, 2006
    #2
    1. Advertising

  3. 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" <> wrote in message
    news:...
    > 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
    Cowboy \(Gregory A. Beamer\), Oct 16, 2006
    #3
  4. 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" <> wrote in message
    news:...
    > 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
    Eliyahu Goldin, Oct 16, 2006
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. babu dhayal via .NET 247

    How to add shared assembly in the add reference

    babu dhayal via .NET 247, Aug 5, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    6,214
    Nelson Xu
    Aug 17, 2004
  2. Chad Scharf
    Replies:
    3
    Views:
    865
    Chad Scharf
    Oct 18, 2007
  3. rs387
    Replies:
    3
    Views:
    265
    rs387
    Oct 2, 2008
  4. tania tani
    Replies:
    0
    Views:
    309
    tania tani
    Aug 3, 2010
  5. tania tani
    Replies:
    0
    Views:
    261
    tania tani
    Aug 3, 2010
Loading...

Share This Page