Datalist disappears after filtering

doraemon

Freshman
Joined
Oct 3, 2003
Messages
36
I am having some problems about filtering the datalist on the ASP .Net page.

My datalist's datasource is bound to a dataview. In the initial page load, I set a filter on the dataview and do a databind and it was working fine. But, in the selectedindexchanged method of a combo box, I did another filter to match the value and then my datalist would disappear. I even tried manually putting the same filter as the initial one and it would still disappear. I wonder why that would happen. Does anyone have any idea?

:o
 
No, I did not. Because if I did, the code would not even run.

Arch4ngel said:
Did you put your DataBind in a condition like this ?
Visual Basic:
If Not Me.IsPostBack Then
   DataBind()
End If
 
Put a Breakpoint in your Page_Load and see what happen if you do.

Each time DataBind() is called it refill the listview. So your selection is out and equal to -1. This can cause some problems.

A little more code should be useful to solve your problem (if it's not already done)
 
I tried many many things and still did not get it to work.

The only way I could get it to work was to call the fill method of the DataAdapter to fill the dataset again, and then it would work. But refilling the dataset takes some time and I don't think it should be the right method. Is there a way I can do so without refilling the dataset?


Arch4ngel said:
Put a Breakpoint in your Page_Load and see what happen if you do.

Each time DataBind() is called it refill the listview. So your selection is out and equal to -1. This can cause some problems.

A little more code should be useful to solve your problem (if it's not already done)
 
That's how web apps work. If you don't want to have to requery the database every time then you may want to look at using Application or Session variables - search in MSDN you will find lots of samples.
Alternatively you may want to investigate the Cache object - can be very useful in this kind of scenario.
 
Are you filtering it with a Where clause in your Select statement? If so, WHY? If not then follow Arch4's suggestion.
 
Back
Top