Blank Row When Adding to DataGrid

Discussion in 'ASP .Net Datagrid Control' started by Jason, Jul 15, 2004.

  1. Jason

    Jason Guest

    I'm working on an aspx page that will display the contents of a
    shopping cart then show the subtotal, any discounts, and the final
    total after that. I'm pulling the contents of the shopping cart from
    a database with the following code:

    MyDataGrid.DataSource = cart.GetItems(cartId); // returns
    // a SqlDataReader
    MyDataGrid.DataBind();

    After this, I would like to add three rows to the end of the DataGrid
    containing the subtotal, discount, and total. To get started, I
    simply want to add a single row to the end with the word "Test" in it.
    I have tried the following code:

    DataGridItem gridItem = new DataGridItem(0, 0, ListItemType.Header);
    TableCell cell = new TableCell();
    cell.ColumnSpan = 5;
    cell.Text = "Test";
    gridItem.Cells.Add(cell);
    MyDataGrid.Controls[0].Controls.Add(gridItem);

    I have tried putting this in the OnItemCreated and OnDataBinding
    events and in both cases got the same result - an emtpy row appended
    to the end of the DataGrid. When I view the source for the page, just
    before the end of the table that is created, there is a <tr> </tr> set
    of tags with nothing inside them.

    If anyone can help me figure out what is going on here and how to get
    this to work, I would greatly appreciate it. I apologize in advance
    if this is a question that gets asked here all the time, but I've
    spent all morning searching for an answer with no luck. Thank you.

    --
    Jason DeCock
    Elk River Systems, Inc.
    http://www.elkriversystems.com
     
    Jason, Jul 15, 2004
    #1
    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. tshad

    Add a blank row to DataGrid

    tshad, Oct 20, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    9,944
    tshad
    Oct 20, 2004
  2. =?Utf-8?B?YWo=?=
    Replies:
    0
    Views:
    410
    =?Utf-8?B?YWo=?=
    Nov 2, 2004
  3. =?Utf-8?B?YWo=?=
    Replies:
    0
    Views:
    355
    =?Utf-8?B?YWo=?=
    Nov 2, 2004
  4. D
    Replies:
    0
    Views:
    230
  5. Jason

    Blank Row When Adding to DataGrid

    Jason, Jul 15, 2004, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    126
    Jason
    Jul 15, 2004
Loading...

Share This Page