473,606 Members | 2,444 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Get updated values in Gridview

Hi all,

I was running into a problem with a gridview under ASP.net. What I am trying
to do is binding the DataSource dynamically in a way that enables me to edit
the rows in the Gridview. This is basically running alright except of the
fact that when I switch to "edit" in a row inside the Gridview and edit the
value and hit "update" I don't find a way to retrieve the changed values.

Here's what I did:
I placed a DataGrid control on my aspx page and bind it dynamically to a
datatable like the following:

With Me.DataGrid
.DataSource = _oClient.GetCal culationDetails (1) 'this retrieves a
datatable
.AutoGenerateEd itButton = True
.DataBind()
End With

the RowEditing-Event is filled with

Me.DataGrid.Edi tIndex = e.NewEditIndex
DataBind()

Then, in the RowUpdating-Event I am accessing the cell values with

With sender.Rows(e.R owIndex)
_oClient.SetCal culationDetails ( _
CType(.Cells(1) .Controls(0).Te xt, Long), _
.Cells(2).Contr ols(0).Text.ToS tring, _
0, "")
End With

unfortunately I only receive the old values and had no chance to retrieve
the changed - which are obviously the displayed - values. How can I do that/
what's my mistake here ? Even the e.NewValues/ OldValues Collections appear
to be empty.

Any help highly appreciated - thanks in advance!

Joe.
Jun 27 '08 #1
1 1923
i forgot to mention that the datatable consists of a single table query like
SELECT col1, col2 FROM dbo.tbl_Test WHERE id = x

Greets,
Joe.
"Joe Blauth" <ca************ *******@web.des chrieb im Newsbeitrag
news:g2******** **@online.de...
Hi all,

I was running into a problem with a gridview under ASP.net. What I am
trying to do is binding the DataSource dynamically in a way that enables
me to edit the rows in the Gridview. This is basically running alright
except of the fact that when I switch to "edit" in a row inside the
Gridview and edit the value and hit "update" I don't find a way to
retrieve the changed values.

Here's what I did:
I placed a DataGrid control on my aspx page and bind it dynamically to a
datatable like the following:

With Me.DataGrid
.DataSource = _oClient.GetCal culationDetails (1) 'this retrieves a
datatable
.AutoGenerateEd itButton = True
.DataBind()
End With

the RowEditing-Event is filled with

Me.DataGrid.Edi tIndex = e.NewEditIndex
DataBind()

Then, in the RowUpdating-Event I am accessing the cell values with

With sender.Rows(e.R owIndex)
_oClient.SetCal culationDetails ( _
CType(.Cells(1) .Controls(0).Te xt, Long), _
.Cells(2).Contr ols(0).Text.ToS tring, _
0, "")
End With

unfortunately I only receive the old values and had no chance to retrieve
the changed - which are obviously the displayed - values. How can I do
that/ what's my mistake here ? Even the e.NewValues/ OldValues Collections
appear to be empty.

Any help highly appreciated - thanks in advance!

Joe.

Jun 27 '08 #2

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

Similar topics

4
5030
by: Larry Grady | last post by:
Anyone up for a challenge? I've been struggling with this for a few days and was hoping someone could help me. Pouring through all the messageboards I just can't find the solution. We have a GridView that needs to be dynamically designed, depending on what collection of fields our uses want to edit for their product data. We have 400+ fields of information per product so they're selecting a subset of those fields to edit.
12
8684
by: Jim Hammond | last post by:
I am passing the whole object instead or parameters in my select and update methods. I can get the updated object if I set UpdateMethod, let ASP.NET autogenerate an update button, and then press update after making changes, but I don't want that update button. How can I get the updated object when the user presses one of my other action buttons?
1
308
by: Mike Grace | last post by:
Hi, I have a gridview which is using a SqlDataSource to update a table. The SqlDatasource is using a stored procedure to update the table. If I edit a row, change a value and click update the change is successfully applied to the SQL table. After this, the values in the underlying table are changed by another
3
6472
by: Kevin | last post by:
We have a base class that is responsible for creating the navigation and look and feel of our applications. So all our web pages inherit from this base page so they don't have to worry about the look and feel and navigation, only the main content. Everything has woked just fine until we converted to 2.0. Now we have a problem with the new GridView and the paging. With the DataGrid in 1.1, the paging worked just fine. Now with paging...
7
2687
by: Joe Kovac | last post by:
Hi! I have one page with a GridView. Their I can select one item and edit this item on an own page within a DetailsView. After updating the entry I want the user to be able to get back to the same position of the GridView as before. E.g.: The user selected an item on the 3rd of 5 GridView pages. He edits the item and now he shall come back to the updated page 3. How do I achieve this the easies way?
0
1785
by: =?Utf-8?B?Vmlua2k=?= | last post by:
Hello Everyone, I have a gridview. I calculated some values in the gridview for the footer of the gridview so basically I am adding all the values that are displayed in the gridview for each column and displaying the total in the footer of the gridview. Now I export the gridview to excel spreadsheet with the code below. Everything is exported well except the footer value become zero in the excel spreadsheet. Can anyone tell me how can i...
1
9545
by: Steve Kershaw | last post by:
Hi, I'm using the RowUpdating() event of an updatable GridView. I need to see the values of the columns in the updated row. There has got to be a way to do this! Any suggestions? Thanks in advance!
2
1277
by: desinerd | last post by:
Hi All. I am using a GridView to List contacts linked to a logged in User. I can successfully bind the Gridview with a DataTable. And the values in the GridView are correctly displayed. I have a BoundField at Index 0 of the GridView which pulls a value from a Column in the DataSource (datatable). The problem I am facing is that all the values in the cells are coming back as empty strings.
1
1941
by: neobonzi | last post by:
Hello! I'm dynamically creating a GridView bound to a datatable using custom template columns using the following method: protected void ShowGrid(DataTable dt) { int i; int j; for( i = 0; i < dt.Columns.Count; i++) {
0
8449
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8432
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8105
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8310
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5466
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3942
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3987
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2451
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 we have to send another system
1
1561
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.