Inserting into a datagrid from textboxes

liunx

Guest
Hi,

I am having an asp.net form that will have some textboxes to enter person details like name address, date of birth etc..These details have to be stored in sql server.I have to take muliple person details..so what i am doing is i am saving these details one after the other to a datagrid by a button click..finally when all multiple person details are entered, i am inserting into the database using a submit button...my datagrids page count is set to 10.so The problem i am facing is i am not able to save more than 10 records ..the 11th record is overwritting the 10th one..Could anybody please help me to sort out this..the code i am using is as below...
Private Sub wbtnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles wbtnSave.Click
Dim dtb As New DataTable
Dim rowNew As DataRow


dtb = ChangeGrid_To_Datatable(employeedetails)

rowNew = dtb.NewRow
rowNew("Employee_Name") = txt_name.Text.Trim
rowNew("Address1") = txt_add1.Text.Trim
rowNew("Address2") = txt_add2.Text.Trim

rowNew("age") = txt_witness_age.Text.Trim

rowNew("D_O_B") = txt_wdob.Text.Trim
rowNew("zip") = txtwitness_zip.Text.Trim
rowNew("Phone") = txtwitness_phone.Text.Trim
rowNew("Email") = txtwitness_email.Text.Trim
dtb.Rows.Add(rowNew)
dtb.AcceptChanges()
employeedetails.DataSource = dtb
employeedetails.DataBind()

dtb.AcceptChanges()
employeedetails.DataSource = dtb
employeedetails.DataBind()

End Sub

Note:ChangeGrid_To_Datatable(employeedetails) is a function within the code that will convert the datagrid to a datatable.
Could anybody please help me to sort out this.

Thanks and Regards
DhanyaHi,
I need some more details to determine if the problem is the data insertion to the table or the data binding:
1. Set a break point at employeedetails.DataSource = dtb and let me know how many rows are in dtb at before the binding (by the way, there is a great tool called "XML Visualizer" which allows you to get a visual view of the Datatable at runtime).
2. provide the full HTML code of the Datagrid definition.

Alon
 
Back
Top