fguihen Posted December 5, 2005 Posted December 5, 2005 this is the way i find out if i have added a row to a dataset or not. there is a boolean value and after the row is added for the first time i set the value to false, so the next time the row is edited rather than added again. i can do this as the dataset is empty when i start, and i am only adding one row. im sure there is a more professional and better way to do this. can anyone tell me how they do it? if(workRecordCreated == false) { workRow = ds.Tables["work_details"].NewRow(); workRow["patient_id"] = guid; workRow["sitting"] = this.chkSit.Enabled; workRow["details"] = this.details.text; } else { ds.Tables["work_details"].Rows[ds.Tables["work_details"].Rows.Count-1].BeginEdit(); ds.Tables["work_details"].Rows[ds.Tables["work_details"].Rows.Count-1]["sitting"] = this.chkSit.Enabled; ds.Tables["work_details"].Rows[ds.Tables["work_details"].Rows.Count-1]["details"] = this.details.text; ds.Tables["work_details"].Rows[ds.Tables["work_details"].Rows.Count-1].EndEdit(); } Quote
otpiness Posted December 6, 2005 Posted December 6, 2005 1. DataTable has got property called PrimaryKey and then use DataTable.Rows.Find() 2. DataTable.Select() has two very usefull overloads and then count on the Rows>0 Hope this helps Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.