I solved the casting error by binding dGrid.DataSource = dataTable;
However, running the previous statement gets the column location in the dataset NOT the datagrid.
This is a show stopper because I move columns around and must bindContents()
Ideas. Why is this difficult?
Steve B. said:
Thanks for your input. A runtime error states a "Specified cast [DataTable] is invalid"
object a = dGrid.DataSource; //returns DataView obj
I also know the table name as well as the column name
Steve
Shakir Hussain said:
Try this
string myText = "My Column Text";
int position= ((DataTable)this.dataGrid1.DataSource).Columns[myText].Ordinal
--
Shak
(Houston)
How do I find the column (index) number at runtime of a particular
DataGrid column if I know the column header string
//somthing like the following
int x = datagrid.column["ID"];