[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

microsoft.public.dotnet.framework.aspnet.caching

RE: DropDownList losing items when using varybycontrol

Manish Bafna

12/9/2006 2:32:00 AM

Hi,
I would loke to suggest you better solution.From the post it looks you dont
want to refreash the page when user changes an item in dropdown and it should
be fast.I would suggest you go for AJAX(Asynchronous Javascript and
XML).According to me AJAX is perfect in your situation.By using AJAX you will
be able to prevent DB Call and It will be fast also.

Thanks and Regards,
manish bafna

"Phil Todd" wrote:

> Greetings,
>
> I hope someone can shed some light on this 'feature' of asp.net caching. I'm
> trying to enable fragment caching with little luck. I suspect I'm missing
> something fundamental here.
>
> I'm trying to use output caching on a user control that contains a
> dropdownlist and a gridview. When the user changes the selected item on the
> dropdownlist - the grid reloads. I'd like to use caching to prevent the
> application doing a db call to reload the grid each time a different
> selection is made. I've set the outputcache directive on the user control
> to:
>
> <%@ OutputCache Duration="60" VaryByControl="DropDownList1" %>
>
>
> I run into problems when a cache hit occurs i.e. the user has selected an
> item for the second time. From then on selecting an item which has been
> selected before results in a cached page as expected. However if an item is
> selected which has not already been cached - the SelectedIndexChanged event
> does not fire and the DropDownList seems to lose it's viewstate. It no
> longer has any items.
>
> I've seen samples from Microsoft that work correctly but they have the
> DropDownList items declared in the ascx code. I've also found that if I
> reload the DropDownList on each page load it will work, but i don't want to
> have to do that as that requires a database query.
>
> Can anyone shed some light on this?
>
>
> Cheers,
> Phil
>
>
> BTW - I've added a test project to this posting which shows the problem. It
> contains one web form and one web user control. It requires a connection to
> the NorthWind DB.
>
>
> To reproduce the behaviour:
>
> 1. Set CachingTest.aspx as the start page
> 2. Choose two different customers using the DropDownList
> 3. Select one of the previously chosen customers to get a cache hit
> 4. Select a previously unselected customer to see the problem
>
>
>