Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here's a few utilities I wrote years ago that may help you:</p> <pre><code>// ---- GetCellByName ---------------------------------- // // pass in a GridViewRow and a database column name // returns a DataControlFieldCell or null static public DataControlFieldCell GetCellByName(GridViewRow Row, String CellName) { foreach (DataControlFieldCell Cell in Row.Cells) { if (Cell.ContainingField.ToString() == CellName) return Cell; } return null; } // ---- GetColumnIndexByHeaderText ---------------------------------- // // pass in a GridView and a Column's Header Text // returns index of the column if found // returns -1 if not found static public int GetColumnIndexByHeaderText(GridView aGridView, String ColumnText) { TableCell Cell; for (int Index = 0; Index &lt; aGridView.HeaderRow.Cells.Count; Index++) { Cell = aGridView.HeaderRow.Cells[Index]; if (Cell.Text.ToString() == ColumnText) return Index; } return -1; } // ---- GetColumnIndexByDBName ---------------------------------- // // pass in a GridView and a database field name // returns index of the bound column if found // returns -1 if not found static public int GetColumnIndexByDBName(GridView aGridView, String ColumnText) { System.Web.UI.WebControls.BoundField DataColumn; for (int Index = 0; Index &lt; aGridView.Columns.Count; Index++) { DataColumn = aGridView.Columns[Index] as System.Web.UI.WebControls.BoundField; if (DataColumn != null) { if (DataColumn.DataField == ColumnText) return Index; } } return -1; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload