473,406 Members | 2,843 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,406 software developers and data experts.

Accessing editable controls in DataGrid update handler

I am having a problem accessing changed values in TextBoxes returned via the OnUpdaterow event. Using C# I access the control using: string _txtAmt = ((TextBox)e.Item.FindControl("txtAmount")).Text

Upon inspection of _txtAmt, the old (pre-edited) value of the textbox is returned versus the changed (edited) value. Using the FindControl method should work, right? I see a lot of examples using an indexer into the e.Item.Cells[n].Controls[n] to retrieve the control but couldn't figure out which indexer was correct to reference the textbox. If I used the 0th element, I received a literal control rather than the textbox and couldn't cast it into what I needed to read the value.

Would appreciate any help
EddieG
Nov 18 '05 #1
2 2083
Hi,

is it sure you are not rebinding the grid on postback accidentally so that
it would mix things up. E.g bind the grid inside IsPostBack check In
Page_load and then only when necessary by the logic (when grid needs to be
rebind i.e when data has changed)

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist
"EddieG" <Un*****************@Unreal.hotmail.com> wrote in message
news:44**********************************@microsof t.com...
I am having a problem accessing changed values in TextBoxes returned via
the OnUpdaterow event. Using C# I access the control using: string _txtAmt
= ((TextBox)e.Item.FindControl("txtAmount")).Text;

Upon inspection of _txtAmt, the old (pre-edited) value of the textbox is
returned versus the changed (edited) value. Using the FindControl method
should work, right? I see a lot of examples using an indexer into the
e.Item.Cells[n].Controls[n] to retrieve the control but couldn't figure
out which indexer was correct to reference the textbox. If I used the 0th
element, I received a literal control rather than the textbox and couldn't
cast it into what I needed to read the value.

Would appreciate any help.
EddieG

Nov 18 '05 #2
Hi,

is it sure you are not rebinding the grid on postback accidentally so that
it would mix things up. E.g bind the grid inside IsPostBack check In
Page_load and then only when necessary by the logic (when grid needs to be
rebind i.e when data has changed)

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist
"EddieG" <Un*****************@Unreal.hotmail.com> wrote in message
news:44**********************************@microsof t.com...
I am having a problem accessing changed values in TextBoxes returned via
the OnUpdaterow event. Using C# I access the control using: string _txtAmt
= ((TextBox)e.Item.FindControl("txtAmount")).Text;

Upon inspection of _txtAmt, the old (pre-edited) value of the textbox is
returned versus the changed (edited) value. Using the FindControl method
should work, right? I see a lot of examples using an indexer into the
e.Item.Cells[n].Controls[n] to retrieve the control but couldn't figure
out which indexer was correct to reference the textbox. If I used the 0th
element, I received a literal control rather than the textbox and couldn't
cast it into what I needed to read the value.

Would appreciate any help.
EddieG

Nov 18 '05 #3

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

Similar topics

8
by: Ashish Shridharan | last post by:
Hi All I have been trying to add a control to the header cell of a datagrid on my ASP.NET page. These controls are defined in the HTML as ASP.NET web controls. They are being added into the...
3
by: Kevin Pedersen | last post by:
Hello, I am using an editable datagrid. After I save the changes the datagrid shows the old values. I've read the posts about the Page_Load and not binding the datagrid each time. The SQL that...
2
by: zambizzi | last post by:
....I can't seem to get my hands on a control I'm loading in an editable datagrid. Here's my datagrid control: <asp:datagrid id="GLRulesGrid" runat="server" autogeneratecolumns="False"...
0
by: Daniel Doyle | last post by:
Hello and apologies in advance for the amount of code in this post. I've also sent this message to the Sharepoint group, but thought that ASP.NET developers may also be able to help, even though...
7
by: Diane | last post by:
Hi- I've been struggling with this problem and none of the fixes posted seem to help out at all. Yet, it seems like such a simple problem... I have a DataGrid, and load it up with data on...
1
by: Joe Spears | last post by:
Hi I want to display a datagrid summary of a datatable. The grid will not show all the fields, but when the user selects a row, I want the other controls (text boxes) to also bind to the same row...
7
by: =?Utf-8?B?Li46OiBLZXZpbiA6Oi4u?= | last post by:
I have a problem with accessing controls that I have loaded dynamically and added to a web page. The scenario: I have a webpage that displays multiple instances of a user control on the page. ...
5
by: rcoco | last post by:
Hi, I'm working on a asp.net project with a datagrid. I want the user to be adding data into Sql database using the datagrid. So I'm using a ListBox to do this and edit update and delete. I placed...
4
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
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?
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...
0
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...
0
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
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...

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.