insert data

Posted by Parag under ASP.NET on 9/17/2008 | Views : 1304 | Status : [Member] | Replies : 5
how to insert data using button click from grid to database ?
i mean to say , i have one grid and two button one add new and save
when i click on add new then new row could be added in grid and when i click on save button then
i want to save all those data which are added in new row will be added in database

note : i used BO /custom entitty classes not dataset

parag barot


Responses

Posted by: Jayakumars on: 9/30/2012 [Member] [MVP] Bronze | Points: 25
Posted by: Jayakumars on: 9/30/2012 [Member] [MVP] Bronze | Points: 25

Up
0
Down
hi
Please mark as answer if it helpful to you.

Mark as Answer if its helpful to you

Parag, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Majith on: 9/17/2008 [Member] Starter

Up
0
Down
Hi Parag,

For New Button Click

DataTable datatable = ds.Tables[0];
DataRow dr = dt.DefaultView.Table.NewRow();
datatable .Rows.InsertAt(dr, 0);

For Saving Data

find the text box controls
TextBox txtname = (TextBox)GridView1.Rows[i].FindControl("txtName");
Row["Name"] = txtname;
DataTable dt = new DataTable();
DataColumn dclm = new DataColumn();
dTable.Columns.Add(dclm );
DataRow dr = dTable.NewRow();
GridView1.DataSource=dt;
GridView1.DataBind();

try this





Parag, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Siya on: 9/17/2008 [Member] Starter

Up
0
Down
i used ultrawebgrid in my project
so how to find out that newley added row data in save button click


Parag, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vuyiswamb on: 9/18/2008 [Member] [MVP] [Administrator] NotApplicable

Up
0
Down
hi , i have Writen Articles on CodeProject about Searching , Updatating and Deleteting in a Datagrid. What you can do is to add the Delete command. look at it here

http://www.codeproject.com/KB/cs/N-Tier22.aspx

Hope it Helps

Thank you for posting at Dotnetfunda
[Administrator]

Parag, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response