[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.aspnet.mobile

Interesting Error Moving From Form to Form

Doug Thews

4/9/2002 6:53:00 AM

I've got a 3-form page in my MMIT application. The first form allows the
user to enter filter criteria and has a 'Search' button. The 2nd form
displays all of the results in an Object list, and has a Command event to do
an event on a specific item in the list. And the 3rd form displays the
results of doing the event on the item in the list and has a button to go
back to the first form and start again.

All appears to work fine, except when I go through the process the second
time. I get an invalided SelectedItemIndex = -1 error when going to the
second form. This is obviously in reference to the selected index of the
ObjectList on Form 2. I can workaround the error by manually setting the
selected index of the object list to 0 manually in the Activate method of
Form 2 (which I don't think I should have to do - especially since this all
worked the first pass through).

Here's a synopsis of the code/form progression:

Form #1
OnButtonClick:
Retrieve values from DB based upon textbox filter
Populate dataset and bind dataset to ObjectList on Form #2 (w/DataBind)
Set Active Form = Form #2

Form #2
OnItemSelectCommand:
Retrieve item selected
Perform action in DB against item selected
Set success/fail status to Label on Form #3
Set Active Form = Form #3

Form #3 (use to review results only - no processing)
OnButtonClick:
Set Active Form = Form #1

For the workaround, I created a handler for the Activate event of Form #2
and manually set the SelectedIndex property to 0. Question is, why is this
necessary since I went through and rebound the Object List with a new
dataset in Form #1 again the 2nd time through?

Thoughts?
--
Doug Thews
Director, Software Development
D&D Consulting Services




3 Answers

Sven <nospam

4/9/2002 9:11:00 AM

0

Hi Doug,

try to set your "EnbaleViewState" property on the 3. form to false...

cya
Sven


Doug Thews

4/9/2002 8:52:00 PM

0

OK, I'll give it a try. By removing viewstate, all of my controls will lose
their original values. What I don't understand is why is SelectedItem
cached even after I bind a brand new dataset to the ObjectList and then
navigate to the form that displays the object list? It doesn't work that
way for a datagrid in ASP.NET (although in ASP.NET you don't traditionally
move from form to form within the same page like this).

--
Doug Thews
Director, Software Development

"Sven" <nospam:sven.betzold@dubidot.com> wrote in message
news:#jt1aW53BHA.2616@tkmsftngp04...
> Hi Doug,
>
> try to set your "EnbaleViewState" property on the 3. form to false...
>
> cya
> Sven
>
>


Doug Thews

4/14/2002 7:27:00 PM

0

Nope, that doesn't work either. Turns out that the ObjectList controls
works a little differently than the ASP.NET DataGrid. If you want to
cyclically move through forms like this with an ObjectList in one of them
(that gets changed), then you need to reset the ViewMode in order to reset
the ObjectList back to a default state:

ObjectList1.ViewMode = ObjectListViewMode.List

--
Doug Thews
Director, Software Development
D&D Consulting Services


"Sven" <nospam:sven.betzold@dubidot.com> wrote in message
news:#jt1aW53BHA.2616@tkmsftngp04...
> Hi Doug,
>
> try to set your "EnbaleViewState" property on the 3. form to false...
>
> cya
> Sven
>
>