473,382 Members | 1,726 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,382 software developers and data experts.

Retrieve the updated values from datagrid

I have an asp.net application in which i have a form containing a datagrid
when using the update command event i have:
tb = CType(e.Item.Cells(3).Controls(0), TextBox)
subject = tb.Text
this code is supposed to get the new data entered in the text box but i am
getting the old data why?
Nov 19 '05 #1
3 1312


"MaryA" ने लिखा:
I have an asp.net application in which i have a form containing a datagrid
when using the update command event i have:
tb = CType(e.Item.Cells(3).Controls(0), TextBox)
subject = tb.Text
this code is supposed to get the new data entered in the text box but i am
getting the old data why?


In this case, use FindControl method Instead of tb =
CType(e.Item.Cells(3).Controls(0), TextBox)
like this
Dim txt as textbox = CType(e.item.FindControl("Id of textbox"),textbox)

I hope this will work in all cases. if you are loop through the datagrid
then its best way to do for each row.
Nov 19 '05 #2
Hi Mary,

Most likely reason is that you re-bind the datagrid’s data source, hence
data inputted is overwritten by data from database (old value).

HTH

Elton Wang
el********@hotmail.com
"MaryA" wrote:
I have an asp.net application in which i have a form containing a datagrid
when using the update command event i have:
tb = CType(e.Item.Cells(3).Controls(0), TextBox)
subject = tb.Text
this code is supposed to get the new data entered in the text box but i am
getting the old data why?

Nov 19 '05 #3
Sachin thanks for your reply but i cant use this:CType(e.item.FindControl("Id
of textbox"),textbox) coz in datagrid textboxes are created automaticly when
clicking the edit mode so they dont have an index

"Sachin Saki" wrote:


"MaryA" ने लिखा:
I have an asp.net application in which i have a form containing a datagrid
when using the update command event i have:
tb = CType(e.Item.Cells(3).Controls(0), TextBox)
subject = tb.Text
this code is supposed to get the new data entered in the text box but i am
getting the old data why?


In this case, use FindControl method Instead of tb =
CType(e.Item.Cells(3).Controls(0), TextBox)
like this
Dim txt as textbox = CType(e.item.FindControl("Id of textbox"),textbox)

I hope this will work in all cases. if you are loop through the datagrid
then its best way to do for each row.

Nov 19 '05 #4

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

Similar topics

1
by: Bob Kaku | last post by:
I'm trying to retrieve a text value from a MySQL database, put it into an updateable form, allow edits, and send back the edited text back into the MySQL database. I've been able to successfully...
0
by: booksnore | last post by:
Help, I have a DataGrid with the Edit, Update and Cancel Columns selected to provide edit by TextBoxs of fields in a table in SQL Server. When I select Edit the Update and Cancel options appear -...
3
by: Alex | last post by:
How can I retrieve a DataRow from the DataGrid in the update handler? Can I do this or do I need to construct one?
0
by: Newasps | last post by:
Hi guys, I have a problem with UpdateCommand Event. In tihs event Ä°'m creating required controls to get that controls' values and also get them. But when I try to get updated values I'm getting the...
0
by: Ozer | last post by:
Hi guys, I need some help. In my datagrid's updatecommand event i'm trying to get textboxes values and also do it. But when i update the values in textboxes and fire the event, I can't get the...
0
by: Anil Kumar Lakky Reddy | last post by:
I have seen lots of people complaining about not getting updated values from edit columns of datagrid. I had similar problem, I figured I was refreshing the data on each page load. I fixed it by...
2
by: Uncle_Albert | last post by:
Hi peeps, Here's a screenshot of a particular form in my program. http://www.jdr.dsl.pipex.com/dg1.JPG Basically, when I click on 'Refresh Totals', I want it to retrieve all values from the...
0
by: Tuomo | last post by:
Hi! I have a form (System.Web.UI.Page) that contains a DataGrid control and a DataTable that contains values for the data grid and that is data bound to the DataGrid. When I switch the grid to...
1
by: divya | last post by:
Hello, I used the below code to move selected items between two listboxes Left and Right:- <%@ Page Language="C#" AutoEventWireup="true" CodeFile="TestPopup.aspx.cs" Inherits="TestPopup" %> ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: 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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.