MyTable.PrimaryKey = new DataColumn[] {MyTable.Columns["MyColumn"]}; DataRow Dr = MyTable.Rows.Find("valuetosearch"); if(Dr!=null) { // run your code based on the hitYou can also create a primary key with multiple columns. Note that the primary key you define MUST be unique. If not, you'll get an error message.
foreach(DataRow DrDetail in MyTable.Rows) MessageBox.Show("Value of invoice id is " + DrDetail["invoiceid"].ToString());Now...if you're scanning through a dataview associated with a rowfilter, you might want to do something like this...
MyTable.DefaultView.RowFilter = " paid = true "; foreach(DataRow drv in MyTable.DefaultView) \\ code for drvThe on-line help has some additional code examples, if you search on the keywords "primary key", "rowfilter", "find", etc.