Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Need to intercept DropDownList.OnSelectedIndexChanged()

Reply
Thread Tools

Need to intercept DropDownList.OnSelectedIndexChanged()

 
 
Jeff Bowman
Guest
Posts: n/a
 
      12-12-2003
I have an editable DataGrid that contains a few
DropDownLists in its EditRow. Each
DropDownList.AutoPostBack is set to True, and each
DropDownList.OnSelectedIndexChanged calls a server-side
method.

The form contains a hidden field called 'txtUserMode',
and I use it to store one of these three values:

0 - Adding
1 - Editing
2 - Viewing

I do this because I have code in ItemCreated that needs
to know what state the grid is currently in, so it can do
all kinds of magic stuff. To this end, I set
txtUserMode.Value in the DataGrid's EditCommand event,
and also in the UpdateCommand and CancelCommand events.

This all works fine until I select a value from one of
the DropDownLists, and the form posts back--I'm then not
able to pick up the correct UserMode from within
ItemCreated, where my crucial logic lies. You see, the
txtUserMode field is set to 2 by default, so when there's
no EditCommand event the grid always thinks it's in
Viewing mode.

I tried setting txtUserMode.Value from within one of the
DropDownList's server-side methods, but unfortunately the
field doesn't pick up the new value before ItemCreated
fires. The same is the case if I use a
RegisterStartupScript approach from within the
OnSelectedIndexChanged methods.

I'm thinking I might be able to work around this problem
if I can have DropDownList.OnSelectedIndexChanged call a
javascript on the client side to set the value of
txtUserMode BEFORE postback, and then in turn have that
javascript execute the standard .NET postback.

I've scoured the net for leads and ideas, but I'm running
into the old problem of "If you don't know you're looking
for a needle, how do you find it in the haystack?"

Is there a way to intercept the DropDownList's standard
PostBack code, and inject my own script call? If so, how
do I then have my script call the standard PostBack?

TIA


 
Reply With Quote
 
 
 
 
Jeff Bowman
Guest
Posts: n/a
 
      12-13-2003
I solved the problem by moving my code from ItemCreated
to ItemDataBound.


>-----Original Message-----
>I have an editable DataGrid that contains a few
>DropDownLists in its EditRow. Each
>DropDownList.AutoPostBack is set to True, and each
>DropDownList.OnSelectedIndexChanged calls a server-side
>method.
>
>The form contains a hidden field called 'txtUserMode',
>and I use it to store one of these three values:
>
>0 - Adding
>1 - Editing
>2 - Viewing
>
>I do this because I have code in ItemCreated that needs
>to know what state the grid is currently in, so it can

do
>all kinds of magic stuff. To this end, I set
>txtUserMode.Value in the DataGrid's EditCommand event,
>and also in the UpdateCommand and CancelCommand events.
>
>This all works fine until I select a value from one of
>the DropDownLists, and the form posts back--I'm then not
>able to pick up the correct UserMode from within
>ItemCreated, where my crucial logic lies. You see, the
>txtUserMode field is set to 2 by default, so when

there's
>no EditCommand event the grid always thinks it's in
>Viewing mode.
>
>I tried setting txtUserMode.Value from within one of the
>DropDownList's server-side methods, but unfortunately

the
>field doesn't pick up the new value before ItemCreated
>fires. The same is the case if I use a
>RegisterStartupScript approach from within the
>OnSelectedIndexChanged methods.
>
>I'm thinking I might be able to work around this problem
>if I can have DropDownList.OnSelectedIndexChanged call a
>javascript on the client side to set the value of
>txtUserMode BEFORE postback, and then in turn have that
>javascript execute the standard .NET postback.
>
>I've scoured the net for leads and ideas, but I'm

running
>into the old problem of "If you don't know you're

looking
>for a needle, how do you find it in the haystack?"
>
>Is there a way to intercept the DropDownList's standard
>PostBack code, and inject my own script call? If so, how
>do I then have my script call the standard PostBack?
>
>TIA
>
>
>.
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Intercept audio content Mark Shaw Firefox 2 07-22-2004 04:41 AM
HttpModule -- how to intercept urls like http://localhost/abc/def or http://localhost/abc/def/ where abc, def are non virtual dir Jiong Feng ASP .Net 0 11-19-2003 05:29 AM
Re: How to intercept an event in ASP.NET? John Saunders ASP .Net 2 08-06-2003 08:11 PM
Re: How to intercept an event in ASP.NET? Steve C. Orr, MCSD ASP .Net 0 08-05-2003 09:46 PM
autopostback - javascript intercept and cancel Susan van Houen ASP .Net 2 07-17-2003 08:15 PM



Advertisments