473,383 Members | 1,855 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

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.GetCalculationDetails(1) 'this retrieves a
datatable
.AutoGenerateEditButton = True
.DataBind()
End With

the RowEditing-Event is filled with

Me.DataGrid.EditIndex = e.NewEditIndex
DataBind()

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

With sender.Rows(e.RowIndex)
_oClient.SetCalculationDetails( _
CType(.Cells(1).Controls(0).Text, Long), _
.Cells(2).Controls(0).Text.ToString, _
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 1914
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.deschrieb 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.GetCalculationDetails(1) 'this retrieves a
datatable
.AutoGenerateEditButton = True
.DataBind()
End With

the RowEditing-Event is filled with

Me.DataGrid.EditIndex = e.NewEditIndex
DataBind()

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

With sender.Rows(e.RowIndex)
_oClient.SetCalculationDetails( _
CType(.Cells(1).Controls(0).Text, Long), _
.Cells(2).Controls(0).Text.ToString, _
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
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...
12
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...
1
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...
3
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...
7
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...
0
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...
1
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...
2
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...
1
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) { ...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.