Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

javascript innerHTML not persisting in gridview edit row

0 views
Skip to first unread message

rodchar

unread,
Apr 11, 2008, 6:09:00 PM4/11/08
to
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

wis...@googlemail.com

unread,
Apr 13, 2008, 12:38:51 PM4/13/08
to
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:

rodchar

unread,
Apr 15, 2008, 10:27:01 PM4/15/08
to
thank you for the insight,
rod.
0 new messages