473,503 Members | 2,049 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Insert Row in GridView using SqlDataSource and update to database ?

I added new rows to the GridView with the following code.

I am using SqlDataSource and Sql Server 2000 Northwind Database Customers
table.

Dim sqlarg As New DataSourceSelectArguments

Dim dv As New System.Data.DataView

dv = SqlDataSource1.Select(sqlarg)

Dim drNewRow As Data.DataRowView = dv.AddNew

drNewRow(0) = "LUQ1"

drNewRow(1) = "LUQMAN"

drNewRow.EndEdit()

GridView.DataSource=dv

GridView.DataBind()

The above code is just adding the row on the fly, but after adding various
rows, I want two choices.

1. Either Exit from the Web Form and Cancel all the updates.

2. Transfer the updated Rows, back to the Database.

How can I achieve the above Two Scenarios.

I want to Add/Edit Records within the Dataset, use them for calculations and
then finally update batch to the database or cancel the update.

Any idea please ?

Best Regards,

Luqman




Nov 16 '07 #1
5 13268
You can add a new row to the Grid by adding a button in the footer and then
add the data and update the data in the database by clicking the update
button...

Regards,
Manish

"Luqman" wrote:
I added new rows to the GridView with the following code.

I am using SqlDataSource and Sql Server 2000 Northwind Database Customers
table.

Dim sqlarg As New DataSourceSelectArguments

Dim dv As New System.Data.DataView

dv = SqlDataSource1.Select(sqlarg)

Dim drNewRow As Data.DataRowView = dv.AddNew

drNewRow(0) = "LUQ1"

drNewRow(1) = "LUQMAN"

drNewRow.EndEdit()

GridView.DataSource=dv

GridView.DataBind()

The above code is just adding the row on the fly, but after adding various
rows, I want two choices.

1. Either Exit from the Web Form and Cancel all the updates.

2. Transfer the updated Rows, back to the Database.

How can I achieve the above Two Scenarios.

I want to Add/Edit Records within the Dataset, use them for calculations and
then finally update batch to the database or cancel the update.

Any idea please ?

Best Regards,

Luqman




Nov 19 '07 #2
My question is, what will be the coding behing Update Button, to update the
Database ?

Best Regards,

Luqman

"Manish" <Ma****@discussions.microsoft.comwrote in message
news:69**********************************@microsof t.com...
You can add a new row to the Grid by adding a button in the footer and
then
add the data and update the data in the database by clicking the update
button...

Regards,
Manish

"Luqman" wrote:
I added new rows to the GridView with the following code.

I am using SqlDataSource and Sql Server 2000 Northwind Database
Customers
table.

Dim sqlarg As New DataSourceSelectArguments

Dim dv As New System.Data.DataView

dv = SqlDataSource1.Select(sqlarg)

Dim drNewRow As Data.DataRowView = dv.AddNew

drNewRow(0) = "LUQ1"

drNewRow(1) = "LUQMAN"

drNewRow.EndEdit()

GridView.DataSource=dv

GridView.DataBind()

The above code is just adding the row on the fly, but after adding
various
rows, I want two choices.

1. Either Exit from the Web Form and Cancel all the updates.

2. Transfer the updated Rows, back to the Database.

How can I achieve the above Two Scenarios.

I want to Add/Edit Records within the Dataset, use them for calculations
and
then finally update batch to the database or cancel the update.

Any idea please ?

Best Regards,

Luqman






Nov 20 '07 #3
You do not need to write code behind the update button. Infact, you will have
to write the SQL update query in the sqldatasource updateQuery property for
updating the database when you click the update button in the GridView
control.

Regards.
Manish

"luqman" wrote:
My question is, what will be the coding behing Update Button, to update the
Database ?

Best Regards,

Luqman

"Manish" <Ma****@discussions.microsoft.comwrote in message
news:69**********************************@microsof t.com...
You can add a new row to the Grid by adding a button in the footer and
then
add the data and update the data in the database by clicking the update
button...

Regards,
Manish

"Luqman" wrote:
I added new rows to the GridView with the following code.
>
I am using SqlDataSource and Sql Server 2000 Northwind Database
Customers
table.
>
Dim sqlarg As New DataSourceSelectArguments
>
Dim dv As New System.Data.DataView
>
dv = SqlDataSource1.Select(sqlarg)
>
Dim drNewRow As Data.DataRowView = dv.AddNew
>
drNewRow(0) = "LUQ1"
>
drNewRow(1) = "LUQMAN"
>
drNewRow.EndEdit()
>
GridView.DataSource=dv
>
GridView.DataBind()
>
The above code is just adding the row on the fly, but after adding
various
rows, I want two choices.
>
1. Either Exit from the Web Form and Cancel all the updates.
>
2. Transfer the updated Rows, back to the Database.
>
How can I achieve the above Two Scenarios.
>
I want to Add/Edit Records within the Dataset, use them for calculations
and
then finally update batch to the database or cancel the update.
>
Any idea please ?
>
Best Regards,
>
Luqman
>
>
>
>
>
>
>
>
>
>
>
>
>


Nov 20 '07 #4
< snip >

<You can add a new row to the Grid by adding a button in the footer and then
<add the data and update the data in the database by clicking the update
<button...

<Regards,
<Manish
Ok - I'm about as new as new gets and am reading answers hoping I will learn something.
Placing an button in the footer "seems" simple enough if you mean putting a button from the toolbox
and placing it on the footer. If not please clarify. Also please explain what you mean by add the data as
in add it where? What update button are you referring to and where did it come from?

Sorry if I appear confused, but I'm obviously missing something here.

Alternatively, if you would like to post a sample page that would be even better.

thanks


--
--------------------------------- --- -- -
Posted with NewsLeecher v3.9 Beta 2
Web @ http://www.newsleecher.com/?usenet
------------------- ----- ---- -- -

Nov 22 '07 #5
Hi,

I want to add records on a fly, which will be saved in local dataset and
display in GridView Control, and as soon as I click on update button, all
the records will be transferred to the Database.

If I cancel, all the changes I made in local dataset will be removed from my
PC Local Memory or Dataset.

Best Regards,

Luqman

<ne****@hotmail.comwrote in message
news:02**********************@news.astraweb.com...
< snip >

<You can add a new row to the Grid by adding a button in the footer and
then
<add the data and update the data in the database by clicking the update
<button...

<Regards,
<Manish
Ok - I'm about as new as new gets and am reading answers hoping I will
learn something.
>

Placing an button in the footer "seems" simple enough if you mean putting
a button from the toolbox
and placing it on the footer. If not please clarify. Also please explain
what you mean by add the data as
in add it where? What update button are you referring to and where did it
come from?
>
Sorry if I appear confused, but I'm obviously missing something here.

Alternatively, if you would like to post a sample page that would be even
better.
>
thanks


--
--------------------------------- --- -- -
Posted with NewsLeecher v3.9 Beta 2
Web @ http://www.newsleecher.com/?usenet
------------------- ----- ---- -- -

Nov 22 '07 #6

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

Similar topics

8
5015
by: Mike Kelly | last post by:
I've chosen to implement the "optimistic concurrency" model in my application. To assist in that, I've added a ROWVERSION (TIMESTAMP) column to my main tables. I read the value of the column in my...
7
14784
by: | last post by:
Hello, Does anyone have an idea on how I can filter the data in the gridview control that was returned by an sql query? I have a gridview that works fine when I populate it with data. Now I...
0
2374
by: Mike P | last post by:
Where exactly are the updateparameters of a gridview picked up from? I have created 2 very similar gridviews and given the updateparameters the same names as in my edititemtemplates. Yet this...
1
6112
by: sheenaa | last post by:
Hello Members, I m creating my application forms in ASP.Net 2005 C# using the backend SQL Server 2005. What i have used on forms :: ? On my first form i have used some...
1
10380
by: Evan M. | last post by:
Here's my GridView and my SqlDataSource <asp:GridView ID="ContactHistoryGrid" runat="server" AutoGenerateColumns="False" DataSourceID="ContactHistoryDS" DataKeyNames="JobHistoryID"...
0
2207
by: lamolap | last post by:
i have 1 gridview , a dropdownlist inside a gridview and a commandfield of (edit, update and cancel) my gidview looks like this Edit Surname Initials ...
0
4033
by: troydixon | last post by:
Hello, I am new at this, and have been trying to insert data into a table by using the footer of a gridview (which I dont like) or by using a detials view on the same page that is doing the...
4
9766
by: mohaaron | last post by:
This seems like it should be simple to do but for some reason I have been unable to make it work. I would like to databind a SqlDataSource to a GridView during the click event of a button. This...
0
1659
BeemerBiker
by: BeemerBiker | last post by:
I was wondering if a command like "SqlDataSource1.insert()" can somehow give me the new index that was created when the insert took place. If the insert always occurs at the end of the dataset then...
0
7204
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7282
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6998
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...
1
5018
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
4680
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
3162
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1516
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 ...
1
741
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
391
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.