473,505 Members | 16,940 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Adding new row to datagrid

Is it possible to add a new row programmatically to a datagrid, then store
the new row data to the database? My app needs to prompt the user to add a
new row - fill in the required fields in the datagrid - then store that data
to the database.

Thanks
Jan 8 '08 #1
2 5259
yes its possible
there is property called allownewrow make it true.

and then write a update command.suppose ur using a dataapater
sqldataadapte da=new sqldataadapte ("select* from table ", conn);
datatable dt=new datatable();
da.Fill(dt);
datagrid.source=dt;

sqlcommandbuilder cbd=new sqlcommandbuilder(da);

da.update(dt);
Note:- if there is primary key in the table and u are accessing that primary
key in select command .then u can use sqlcommandbuilderwhich will
automatically generate the updtae insert and delete command.
if there is no primary key in table then u need to write ur own update
command.

"vbtrying" wrote:
Is it possible to add a new row programmatically to a datagrid, then store
the new row data to the database? My app needs to prompt the user to add a
new row - fill in the required fields in the datagrid - then store that data
to the database.

Thanks
Jan 8 '08 #2
Thank you very much for your input ...
"Som Nath Shukla" wrote:
yes its possible
there is property called allownewrow make it true.

and then write a update command.suppose ur using a dataapater
sqldataadapte da=new sqldataadapte ("select* from table ", conn);
datatable dt=new datatable();
da.Fill(dt);
datagrid.source=dt;

sqlcommandbuilder cbd=new sqlcommandbuilder(da);

da.update(dt);
Note:- if there is primary key in the table and u are accessing that primary
key in select command .then u can use sqlcommandbuilderwhich will
automatically generate the updtae insert and delete command.
if there is no primary key in table then u need to write ur own update
command.

"vbtrying" wrote:
Is it possible to add a new row programmatically to a datagrid, then store
the new row data to the database? My app needs to prompt the user to add a
new row - fill in the required fields in the datagrid - then store that data
to the database.

Thanks
Jan 8 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
9992
by: Jim | last post by:
In my Win App, I have a datagrid that's bound to a dataset. When the form loads, the datagrid fills. How can I add an empty row to the end of the datagrid during a button click (similar to...
2
3614
by: Clayton Hamilton | last post by:
I have a DataGrid on a webform bound to a Datasource and can successfully use <ItemTemplate> to create edit/update/cancel functionality for user maintenance of data. I use separate logic to delete...
5
1519
by: Phil Townsend | last post by:
I need to add a button to a datagrid. I have tried using the ButtonColumn and have also tried adding a button to a templatecolumn > itemtemplate. Whatever I have tried doesn't work, nor does it...
3
4856
by: Jim Heavey | last post by:
Trying to figure out the technique which should be used to add rows to a datagrid. I am thinking that I would want an "Add" button on the footer, but I am not quite sure how to do that. Is that...
1
3261
by: Andrew | last post by:
Hey all, I am very new to ASP.Net (and .Net in general), but that isn't stopping the boss from wanting to begin new projects in it. This latest project has me kinda stumped and after a couple...
2
1949
by: Praveen Balanagendra via .NET 247 | last post by:
here is the source code private void AddRow() { TableCell tc = new TableCell(); tc.Controls.Add(new LiteralControl("NewRow")); DataGridItem di = new...
2
2421
by: Bob Hollness | last post by:
Hi group. I am a newbie to ASP.NET as you will see from some of the questions I may ask! I have a datagrid which I have populated from a database. It works great! I have added a column, via...
3
3133
by: Fao, Sean | last post by:
I have a DataGrid that I'm adding CheckBox controls to at runtime (in the code behind) and I'm not sure if I'm doing it correctly. First of all, I noticed that the MyDataGrid.Columns.Add() method...
2
3541
by: Flack | last post by:
Hey guys, I have a DataGrid and DataTable field in my class : private ImageDataGrid dataGrid1; //ImageDataGrid extends dataGrid and just overides OnMouseDown private DataTable dt = new...
1
1874
by: Tor Inge Rislaa | last post by:
Adding HTML tags to data from SQL server When dragging a table on to a web form in an ASP.NET 2.0 application, the connection is established and the data is displayed in a DataGrid. Is it...
0
7370
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7021
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7478
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5614
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5035
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4701
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3188
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1532
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
409
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.