//To SETS THE DATASET PRIMARY KEY
DataCoulumn[] keys = new DataColumn[1];
keys[0] = DataSet.Tables["mytable"].Column["i_ID"];
DataSet.Tables["mytable"].PrimaryKey = keys;
DataCoulumn[] keys = new DataColumn[1];
keys[0] = DataSet.Tables["mytable"].Column["i_ID"];
DataSet.Tables["mytable"].PrimaryKey = keys;
// To Bind in THE DATAGRID VIEW
BindingManagerBase bm;
DataGridView1.DataSource = DataSet.Tables["mytable"].DefaultView;
bm = this.DataGridView1.BindingContext[this.DataGridView1.DataSource, this. DataGridView1.DataMember];
//You have a datarow and u need to find the rowindex of the row in dataset
DataRow findRow = DataSet.Tables["mytable"].Rows.Find(((DataRowView)bm.Current).Row[0]); // Row[0] is the collumn to seach in in this case ID column
int indexNumber = DataSet.Tables["mytable"].Rows.IndexOF(findRow);
1 comments:
Hi Gregor,
thinks a lot for this sample
IndexOf is powerfull
Loic Brengues
Post a Comment