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.
Unfortunately, activation email could not send to your email. Please try again.

DataGrid Adding New Records

Thread ID:

Created:

Updated:

Platform:

Replies:

4338 May 8,2003 04:02 AM Dec 4,2003 05:59 PM Windows Forms 4
loading
Tags: FAQ
Mani
Asked On May 8, 2003 04:02 AM

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

Sameer
Replied On May 8, 2003 09:01 AM

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

Mani
Replied On May 9, 2003 12:58 AM

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 >

Mani
Replied On May 12, 2003 04:09 AM

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

Lavanya.A
Replied On December 4, 2003 05:59 PM

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 >

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;