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

javascript innerHTML not persisting in gridview edit row

hey all,
i'm in a gridview edit row that has a DropDownList in one column and a
status Label in the 2nd column.

When i changed the value in the dropdownlist, there's a client-side
javascirpt function that runs and successfully populates label in the 2nd
column. Everything is fine at this point and working the way it should.

i do a getElementById to get the status label and then i set its innerHTML
and again it works fine.

the problem starts when i try to save the row it the label part does not
persist but oddly enough the dropdownlist value does save. i try to inspect
this in debug mode and sure enough the value for the status label is blank.

shouldn't this persist?

i also tried this. i manually when into sql and changed the value of the
status column. i did the same test above and when i tried to save the row
with the new status value it reverted back to originally what was in the
database. i'm going to try a smaller scale test to see if it does the same
thing, but i just thought i'd go ahead and get this one out there.

thanks,
rodchar

Jun 27 '08 #1
2 3706
Hi Rodchar,

If I understand you correctly, you set the Label's innerHtml by
Javascript, and expect that the new value will get picked up by the
server.

The problem with this is that you change something without "notifying"
the server. The ASP.Net engine doesn't expect that a Label gets
changed, so it will not save those values for you in the way you
expect. This is different from a DropDownList or a TextBox, both of
which implement the IPostbackDataHandler interface. On postback, only
server controls that implement this interface will get a chance to
update their properties on the server side. All other changes that you
make via Javascript will get lost.

Since you set the Label's value based on the DropDownList's, I suggest
that you use the same logic to determine the value that the Label
should have on postback. Or, if you're on ASP.Net 3.5, just use
UpdatePanel.

=============
Regards,
Steve
www.stkomp.com

On Apr 12, 12:09 am, rodchar <rodc...@discussions.microsoft.com>
wrote:
hey all,
i'm in a gridview edit row that has a DropDownList in one column and a
status Label in the 2nd column.

When i changed the value in the dropdownlist, there's a client-side
javascirpt function that runs and successfully populates label in the 2nd
column. Everything is fine at this point and working the way it should.

i do a getElementById to get the status label and then i set its innerHTML
and again it works fine.

the problem starts when i try to save the row it the label part does not
persist but oddly enough the dropdownlist value does save. i try to inspect
this in debug mode and sure enough the value for the status label is blank.

shouldn't this persist?

i also tried this. i manually when into sql and changed the value of the
status column. i did the same test above and when i tried to save the row
with the new status value it reverted back to originally what was in the
database. i'm going to try a smaller scale test to see if it does the same
thing, but i just thought i'd go ahead and get this one out there.

thanks,
rodchar
Jun 27 '08 #2
thank you for the insight,
rod.

"wi*****@googlemail.com" wrote:
Hi Rodchar,

If I understand you correctly, you set the Label's innerHtml by
Javascript, and expect that the new value will get picked up by the
server.

The problem with this is that you change something without "notifying"
the server. The ASP.Net engine doesn't expect that a Label gets
changed, so it will not save those values for you in the way you
expect. This is different from a DropDownList or a TextBox, both of
which implement the IPostbackDataHandler interface. On postback, only
server controls that implement this interface will get a chance to
update their properties on the server side. All other changes that you
make via Javascript will get lost.

Since you set the Label's value based on the DropDownList's, I suggest
that you use the same logic to determine the value that the Label
should have on postback. Or, if you're on ASP.Net 3.5, just use
UpdatePanel.

=============
Regards,
Steve
www.stkomp.com

On Apr 12, 12:09 am, rodchar <rodc...@discussions.microsoft.com>
wrote:
hey all,
i'm in a gridview edit row that has a DropDownList in one column and a
status Label in the 2nd column.

When i changed the value in the dropdownlist, there's a client-side
javascirpt function that runs and successfully populates label in the 2nd
column. Everything is fine at this point and working the way it should.

i do a getElementById to get the status label and then i set its innerHTML
and again it works fine.

the problem starts when i try to save the row it the label part does not
persist but oddly enough the dropdownlist value does save. i try to inspect
this in debug mode and sure enough the value for the status label is blank.

shouldn't this persist?

i also tried this. i manually when into sql and changed the value of the
status column. i did the same test above and when i tried to save the row
with the new status value it reverted back to originally what was in the
database. i'm going to try a smaller scale test to see if it does the same
thing, but i just thought i'd go ahead and get this one out there.

thanks,
rodchar

Jun 27 '08 #3

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

Similar topics

1
by: IkBenHet | last post by:
Hello, I found this script to create a simple rich text form (http://programmabilities.com/xml/index.php?id=17): <html> <head> <title>Rich Text Editor</title> </head> <body>
2
by: xxbmichae1 | last post by:
I am writing a function that will create different type of input ranges, example one function that will create date range inputs with drop down calendars, another will be for currency ranges,...
5
by: Dick | last post by:
I have a GridView bound to an ObjectDataSource. I have a Button that calls GridView.DataBind. I want the row that is selected before the DataBind to still be selected afterwards. This happens...
0
by: kegs01 | last post by:
I am using a JavaScript DHTML Calendar cotrol in the Edit Template of a Grid View, and I'm having trouble getting the setup code to fire properly. I have tried adding the JavaScript using...
7
by: julian.tklim | last post by:
Hi, I need to build an editable Datagrid with add & delete buttons on each row using javascript. DataGrid need not be pre-populated with values. To make the thing complicated, one of the...
1
by: Marc Pavo | last post by:
Since Ajax.net isn't production-worthy yet, I'm looking for any info on this (as well as manipulating GridView from client script in general). Thank you!
5
by: HockeyFan | last post by:
We have an update panel that has a gridview with checkboxes and other items in each row. We went to the RowCreated event in the codebehind, to set an attribute on a checkbox in each row, to...
0
by: =?Utf-8?B?cm9kY2hhcg==?= | last post by:
hey all, i'm in a gridview edit row that has a DropDownList in one column and a status Label in the 2nd column. When i changed the value in the dropdownlist, there's a client-side javascirpt...
1
by: aloksingh83 | last post by:
This error coming when i am using telerik grid.It works fine in asp.net grid what i am trying to do is taking values from textbox and show in grid view... here is the code: <script...
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: 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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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
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...
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.