Click here to Skip to main content
11,480,031 members (66,388 online)
Rate this: bad
Please Sign up or sign in to vote.
private void cmdSave_Click(object sender, EventArgs e)
            dt = hRDataSet.Tables["empdetails"];
            dr = dt.NewRow();

                dr[0] = txtccode.Text;    //argumentexception was unhandled
                dr[1] = txtEmployeeName.Text;
                dr[2] = txtAddress.Text;
                dr[3] = txtState.Text;
                dr[4] = txtCountry.Text;
                dr[5] = cbDepartment.SelectedItem;
                dr[6] = cbDesignation.SelectedItem;
                txtccode.Text = System.Convert.ToString(dr[0]);
                txtccode.Enabled = false;
                txtEmployeeName.Enabled = false;
                txtAddress.Enabled = false;
                txtState.Enabled = false;
                txtCountry.Enabled = false;
                cbDepartment.Enabled = false;
                cbDesignation.Enabled = false;
                cmdAdd.Enabled = true;
                cmdSave.Enabled = false;
Posted 6-Sep-12 4:14am
Edited 6-Sep-12 4:16am
(no name)155.4K
Wes Aday at 6-Sep-12 9:27am
dr is not an array so dr[0] makes no sense.
pinky_sood at 6-Sep-12 9:28am
than what is the way? to store data
deepakaitr12345 at 8-Sep-12 4:56am
you can use the approch like this if you having the datatable to save in database

1)Create the generic Ilist like
IList testList= new List();

2)Create the object of your model and initialise the constructure fo your model class under the for loop

like below

for (int i = 0; i < grdTest.Rows.Count; i++)

testModelObject = new testModel(value1,value2,value3));


and initialse the values in the constructure
apply the for loop on the insert into statement and your problem get resolved.


This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 235
1 Sergey Alexandrovich Kryukov 215
2 Richard MacCutchan 100
3 F-ES Sitecore 75
4 DamithSL 65
0 Sergey Alexandrovich Kryukov 7,890
1 OriginalGriff 7,556
2 Sascha Lefèvre 3,064
3 Maciej Los 2,491
4 Richard Deeming 2,335

Advertise | Privacy | Mobile
Web03 | 2.8.150520.1 | Last Updated 6 Sep 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100