How do I find the index of a DG column with a specific name?

Discussion in 'ASP .Net Datagrid Control' started by Aaron, Aug 17, 2004.

  1. Aaron

    Aaron Guest

    I have a column called "notes" which may change position in the datagrid.
    How do I find the index of this column based on its name?
     
    Aaron, Aug 17, 2004
    #1
    1. Advertising

  2. Aaron

    Aaron Guest

    Could you give me a code example?

    Thanks,
    Aaron


    "Eliyahu Goldin" <> wrote in message
    news:...
    > Iterate through Columns collection.
    >
    > Eliyahu
    >
    > "Aaron" <> wrote in message
    > news:%...
    > > I have a column called "notes" which may change position in the

    datagrid.
    > > How do I find the index of this column based on its name?
    > >
    > >

    >
    >
     
    Aaron, Aug 17, 2004
    #2
    1. Advertising

  3. Aaron

    Aaron Guest

    Thank you very much. This is extremely helpful.


    "Eliyahu Goldin" <> wrote in message
    news:...
    > static public int IndexByName (System.Web.UI.WebControls.DataGrid
    > grid, string name)
    > {
    > for (int col = 0; col < grid.Columns.Count; col++)
    > if (grid.Columns[col].HeaderText == name)
    > return col;
    > return -1;
    > }
    >
    > Eliyahu
    >
    > "Aaron" <> wrote in message
    > news:%...
    > > Could you give me a code example?
    > >
    > > Thanks,
    > > Aaron
    > >
    > >
    > > "Eliyahu Goldin" <> wrote in message
    > > news:...
    > > > Iterate through Columns collection.
    > > >
    > > > Eliyahu
    > > >
    > > > "Aaron" <> wrote in message
    > > > news:%...
    > > > > I have a column called "notes" which may change position in the

    > > datagrid.
    > > > > How do I find the index of this column based on its name?
    > > > >
    > > > >
    > > >
    > > >

    > >
    > >

    >
    >
     
    Aaron, Aug 17, 2004
    #3
  4. Iterate through Columns collection.

    Eliyahu

    "Aaron" <> wrote in message
    news:%...
    > I have a column called "notes" which may change position in the datagrid.
    > How do I find the index of this column based on its name?
    >
    >
     
    Eliyahu Goldin, Aug 17, 2004
    #4
  5. static public int IndexByName (System.Web.UI.WebControls.DataGrid
    grid, string name)
    {
    for (int col = 0; col < grid.Columns.Count; col++)
    if (grid.Columns[col].HeaderText == name)
    return col;
    return -1;
    }

    Eliyahu

    "Aaron" <> wrote in message
    news:%...
    > Could you give me a code example?
    >
    > Thanks,
    > Aaron
    >
    >
    > "Eliyahu Goldin" <> wrote in message
    > news:...
    > > Iterate through Columns collection.
    > >
    > > Eliyahu
    > >
    > > "Aaron" <> wrote in message
    > > news:%...
    > > > I have a column called "notes" which may change position in the

    > datagrid.
    > > > How do I find the index of this column based on its name?
    > > >
    > > >

    > >
    > >

    >
    >
     
    Eliyahu Goldin, Aug 17, 2004
    #5
    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. =?Utf-8?B?TWlrZQ==?=

    get value by index and not column name...

    =?Utf-8?B?TWlrZQ==?=, Feb 1, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    2,910
    Karl Seguin
    Feb 2, 2005
  2. DBLWizard
    Replies:
    1
    Views:
    8,204
    Eliyahu Goldin
    Jul 19, 2005
  3. msnews

    use column name instead of index

    msnews, Sep 28, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    401
    Eliyahu Goldin
    Sep 28, 2005
  4. agora1983
    Replies:
    0
    Views:
    661
    agora1983
    Feb 11, 2008
  5. Tomasz Chmielewski

    sorting index-15, index-9, index-110 "the human way"?

    Tomasz Chmielewski, Mar 4, 2008, in forum: Perl Misc
    Replies:
    4
    Views:
    356
    Tomasz Chmielewski
    Mar 4, 2008
Loading...

Share This Page