473,763 Members | 5,412 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Ite m.FindControl(" txtAmount")).Te xt

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 2096
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.ho tmail.com> wrote in message
news:44******** *************** ***********@mic rosoft.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.Ite m.FindControl(" txtAmount")).Te xt;

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.ho tmail.com> wrote in message
news:44******** *************** ***********@mic rosoft.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.Ite m.FindControl(" txtAmount")).Te xt;

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
7932
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 header of the datagrid in the "ItemDataBound" method of the grid. However, once, they are added in the grid, i seem to lose the event handler for the same control. Is there anyone who has tried this before and knows why this is hapenning ??
3
4934
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 is being sent to the database is correct and the changes are eventually being made. If I refresh the page after the update then the new values appear. I noticed that when I put a breakpoint in my update handler everything works fine. When I take...
2
5040
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" oneditcommand="GLRulesGrid_Edit"
0
1832
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 it's a Sharepoint WebPart. I'm trying to do something fairly simple, create a datagrid that displays where and when a person works and allows them to change some of the information via DropDownLists. When the user clicks to edit a row, three of...
7
2301
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 page load. In my EditCommand event handler I set the editItemindex. All good. Except, the user needs to click twice to get the DataGrid to become editable. It's obvious to me (perhaps worngly) that ASP.NET is storing the data
1
2415
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 that is selected in the grid. However, the controls will bind to ALL of the fields, where the grid will only show some of them. I want to be able to edit the data using the text boxes, and then update. I also want to be able to add data using...
7
2133
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. The number of controls that are displayed can be adjusted by the user so the controls are added to the page dynamically using the following code in the Page_Init event handler: For i as Integer = 1 to NumberOfControls
5
2224
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 listbox in EditItemTemplate and label in ItemTemplate. but when I try now to edit it does not bring the lisbox but i can read the grid with the sql content. my code actually looks like this: public void Edit_dgid(object source,...
4
9790
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 sounds easy but the next requirement is that the GridView is editable. So I have included the SelectCommand and the UpdateCommand on the SqlDataSource to allow the GridView to be editable. I have now been able to get the GridView to display data...
0
9386
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10144
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
9997
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
9937
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
8821
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6642
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
5405
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3522
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2793
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.