Problem with Strong Typed Dataset with DataGridView
-
1.I create a strong typed dataset. 2.I bound the table from the strong Typed dataset to a DataGridView. 3.User Click on a row and press "Select" button. I can just cast the selected row with code below:
this.returnedRow = (TypedDS.MasterGroupSearchRow)this.dgvMasterContract.CurrentRow.DataBoundItem;
4.At this moment the this.dgvMasterContract.CurrentRow.DataBoundItem is (TypedDS.MasterGroupSearchRow) But if After Click on the column header .. problem come out ... this.dgvMasterContract.CurrentRow.DataBoundItem will become System.Data.DataRow. So code below will fail ..this.returnedRow = (TypedDS.MasterGroupSearchRow)this.dgvMasterContract.CurrentRow.DataBoundItem;
Is there anyway to solve this problem ? or is there anyway to preserve it original typed row ? -
1.I create a strong typed dataset. 2.I bound the table from the strong Typed dataset to a DataGridView. 3.User Click on a row and press "Select" button. I can just cast the selected row with code below:
this.returnedRow = (TypedDS.MasterGroupSearchRow)this.dgvMasterContract.CurrentRow.DataBoundItem;
4.At this moment the this.dgvMasterContract.CurrentRow.DataBoundItem is (TypedDS.MasterGroupSearchRow) But if After Click on the column header .. problem come out ... this.dgvMasterContract.CurrentRow.DataBoundItem will become System.Data.DataRow. So code below will fail ..this.returnedRow = (TypedDS.MasterGroupSearchRow)this.dgvMasterContract.CurrentRow.DataBoundItem;
Is there anyway to solve this problem ? or is there anyway to preserve it original typed row ?Check the type before you process the OnClick event? Is this a web grid view or a winform gridview?