Way to look up index for Cell in datagrid

Discussion in 'ASP .Net' started by Paul, Jan 18, 2005.

  1. Paul

    Paul Guest

    Is there a way to look up the index for cells in a data grid. I do not
    like hard coding numbers into my programs (other than 0 or 1)

    Sub DisplayBoundColumnValues(sender as Object, e as
    Dim bc1 as String = e.Item.Cells(1).Text
    Dim bc2 as String = e.Item.Cells(2).Text

    End Sub

    Thank You
    Paul, Jan 18, 2005
    1. Advertisements

  2. Are you looking for a way of accessing cells by column name? Write a simple
    method that will loop through the grid's Columns collection, match column
    names, and return the index of the matched one. This won't work if the
    columns are autogenerated.

    Eliyahu Goldin, Jan 18, 2005
    1. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.