adding more information

Discussion in 'ASP .Net Datagrid Control' started by ashelley@inlandkwpp.com, Jun 15, 2004.

  1. Guest

    Hello,

    If i am binding a datagrid to a dataset, is there anyway to include
    each rows index number so that I can explicly reference it on the
    itemdatabound event regardless of sort order / filtering.

    Here's what I want to do for my ItemDataBound event.

    //xd is a XmlDataDocument that has been stored in a session

    xd.DataSet.Tables["PART"].Rows[int.Parse(e.Item.Cells[0].Text)].GetChildRows("PART_DET");

    where

    e.Item.Cells[0].Text is the original row number as found in the
    dataset?

    -Adam
    , Jun 15, 2004
    #1
    1. Advertising

  2. <> wrote in message
    news:...
    > Hello,
    >
    > If i am binding a datagrid to a dataset, is there anyway to include
    > each rows index number so that I can explicly reference it on the
    > itemdatabound event regardless of sort order / filtering.
    >
    > Here's what I want to do for my ItemDataBound event.
    >
    > //xd is a XmlDataDocument that has been stored in a session
    >
    >

    xd.DataSet.Tables["PART"].Rows[int.Parse(e.Item.Cells[0].Text)].GetChildRows
    ("PART_DET");
    >
    > where
    >
    > e.Item.Cells[0].Text is the original row number as found in the
    > dataset?
    >
    > -Adam
    Eliyahu Goldin, Jun 15, 2004
    #2
    1. Advertising

  3. Adam,

    You can add a column to the grid, populate it with row indexes on the first
    itemdatabound event and make it invisible.

    Eliyahu

    <> wrote in message
    news:...
    > Hello,
    >
    > If i am binding a datagrid to a dataset, is there anyway to include
    > each rows index number so that I can explicly reference it on the
    > itemdatabound event regardless of sort order / filtering.
    >
    > Here's what I want to do for my ItemDataBound event.
    >
    > //xd is a XmlDataDocument that has been stored in a session
    >
    >

    xd.DataSet.Tables["PART"].Rows[int.Parse(e.Item.Cells[0].Text)].GetChildRows
    ("PART_DET");
    >
    > where
    >
    > e.Item.Cells[0].Text is the original row number as found in the
    > dataset?
    >
    > -Adam
    Eliyahu Goldin, Jun 15, 2004
    #3
  4. Guest

    is it a function of the dataset to provide the row index to the
    datagrid in a bound column?

    what is this call?

    ie <asp:boundcolumn datasource="rowindex()"/>?

    -Adam
    , Jun 15, 2004
    #4
  5. Guest

    then if the dataset is filtered or sorted then the row index will be
    incorrect.

    -Adam
    , Jun 15, 2004
    #5
  6. No, just count the rows yourself in ItemDataBound event. Don't forget to
    ignore non-datarow items, like header.

    Eliyahu

    <> wrote in message
    news:...
    >
    > is it a function of the dataset to provide the row index to the
    > datagrid in a bound column?
    >
    > what is this call?
    >
    > ie <asp:boundcolumn datasource="rowindex()"/>?
    >
    > -Adam
    Eliyahu Goldin, Jun 15, 2004
    #6
  7. Guest

    On Tue, 15 Jun 2004 18:29:34 +0200, "Eliyahu Goldin"
    <> wrote:

    >Adam,
    >
    >You are right. I understood that you first show the full table and than
    >sorting or filtering is applied. Apparently it is not the case. You can't
    >use row index simply because it is not something absolute and there is no
    >such a property. You should use table's primary key instead.
    >
    >Eliyahu
    >


    What if there are a couple of thousand records in the dataset? Would
    using primary key be efficient _enough_ in this case?

    The only option I can think of is when generating the dataset make a
    primary key as an integer so that the index in the dataset is directly
    correlated to the primary key,

    but is this the only way?

    -Adam
    , Jun 15, 2004
    #7
  8. Adam,

    You are right. I understood that you first show the full table and than
    sorting or filtering is applied. Apparently it is not the case. You can't
    use row index simply because it is not something absolute and there is no
    such a property. You should use table's primary key instead.

    Eliyahu

    <> wrote in message
    news:...
    >
    > then if the dataset is filtered or sorted then the row index will be
    > incorrect.
    >
    > -Adam
    >
    Eliyahu Goldin, Jun 15, 2004
    #8
    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. z. f.
    Replies:
    0
    Views:
    660
    z. f.
    Feb 3, 2005
  2. subrato
    Replies:
    8
    Views:
    904
    Juan T. Llibre
    Mar 14, 2006
  3. clercmedia
    Replies:
    2
    Views:
    32,228
    clercmedia
    Dec 9, 2005
  4. Michael
    Replies:
    4
    Views:
    392
    Matt Hammond
    Jun 26, 2006
  5. Robert Klemme

    With a Ruby Yell: more, more more!

    Robert Klemme, Sep 28, 2005, in forum: Ruby
    Replies:
    5
    Views:
    194
    Jeff Wood
    Sep 29, 2005
Loading...

Share This Page