We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

DataGrid Adding New Records

I have a datagrid that is bound to a DataTable, containing 3 columns viz. 1.autonumber,2. a look-up column and 3. a column containing values 1 or 2 or 3. The data-entry in the datagrid is done by using a combo-box and a set of radio-buttons to select either of 1,2, or 3. Editing of records is fine and proceeds without any hitch. The main problem is when you try to add a new record. Unless there is a physical keystroke placed on one of the column the new row doesn't seem to ber created and all the changes done are lost if u move to the previous record in DataGrid. Tried to create a new Record programmatically in the DataTable using Rows.Add method as well as in the DataView but none seems to help or work the way it would normally if you are doing normal data-entry without any external controls. Does any one of you know of any way this can be done?. Thanks, Mani

4 Replies

SA Sameer May 8, 2003 01:01 PM UTC

After you add the record to the Table, are you accepting the changes ? I think, all you need to do is , after addnew to the data table, do an acceptchanges. -S > I have a datagrid that is bound to a DataTable, containing 3 columns viz. 1.autonumber,2. a look-up column and 3. a column containing values 1 or 2 or 3. The data-entry in the datagrid is done by using a combo-box and a set of radio-buttons to select either of 1,2, or 3. Editing of records is fine and proceeds without any hitch. The main problem is when you try to add a new record. Unless there is a physical keystroke placed on one of the column the new row doesn't seem to ber created and all the changes done are lost if u move to the previous record in DataGrid. Tried to create a new Record programmatically in the DataTable using Rows.Add method as well as in the DataView but none seems to help or work the way it would normally if you are doing normal data-entry without any external controls. Does any one of you know of any way this can be done?. > > Thanks, > Mani


MA Mani May 9, 2003 04:58 AM UTC

I Presume in a DataGrid AcceptChnages is fired automatically. And you are not supposed to write any specific code for the same. If the fields where my combobox and radio buttons are present are normal DataGridtextboxColumn without another control masking it, the record gets saved automatically when I move the cursor to another record in the grid. > After you add the record to the Table, are you accepting the changes ? > > I think, all you need to do is , after addnew to the data table, do an acceptchanges. > > -S > > > I have a datagrid that is bound to a DataTable, containing 3 columns viz. 1.autonumber,2. a look-up column and 3. a column containing values 1 or 2 or 3. The data-entry in the datagrid is done by using a combo-box and a set of radio-buttons to select either of 1,2, or 3. Editing of records is fine and proceeds without any hitch. The main problem is when you try to add a new record. Unless there is a physical keystroke placed on one of the column the new row doesn't seem to ber created and all the changes done are lost if u move to the previous record in DataGrid. Tried to create a new Record programmatically in the DataTable using Rows.Add method as well as in the DataView but none seems to help or work the way it would normally if you are doing normal data-entry without any external controls. Does any one of you know of any way this can be done?. > > > > Thanks, > > Mani >


MA Mani May 12, 2003 08:09 AM UTC

Here is my code. Please look into it and tell me what am i missing? In This code instead of a panel containing the radio buttons, I have a combo box. If i remove the combos and keep my normal DataGridTextBox columns everything works fine. Mani > After you add the record to the Table, are you accepting the changes ? > > I think, all you need to do is , after addnew to the data table, do an acceptchanges. > > -S


LA Lavanya.A December 4, 2003 10:59 PM UTC

Hi, Even accept changes doesn't seem to work. What i have done to solve this problem is ... 1. Have a dataset 2. Bind the dataset to this Grid. 3. Write code in the current cell changed event, when the first column has a value, call a function. 4. In that function, physically add a row to the dataset, then bind the grid to the new dataset. This is working fine with my project. If you need any clarifications, Pls do mail me. If there is any better solutions, pls do let me as well. Regards Lavanya.A (lavanyaa0@yahoo.com) > After you add the record to the Table, are you accepting the changes ? > > I think, all you need to do is , after addnew to the data table, do an acceptchanges. > > -S > > > I have a datagrid that is bound to a DataTable, containing 3 columns viz. 1.autonumber,2. a look-up column and 3. a column containing values 1 or 2 or 3. The data-entry in the datagrid is done by using a combo-box and a set of radio-buttons to select either of 1,2, or 3. Editing of records is fine and proceeds without any hitch. The main problem is when you try to add a new record. Unless there is a physical keystroke placed on one of the column the new row doesn't seem to ber created and all the changes done are lost if u move to the previous record in DataGrid. Tried to create a new Record programmatically in the DataTable using Rows.Add method as well as in the DataView but none seems to help or work the way it would normally if you are doing normal data-entry without any external controls. Does any one of you know of any way this can be done?. > > > > Thanks, > > Mani >

Loader.
Live Chat Icon For mobile
Up arrow icon