doraemon Posted April 6, 2004 Posted April 6, 2004 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 Quote
Arch4ngel Posted April 6, 2004 Posted April 6, 2004 Did you put your DataBind in a condition like this ? If Not Me.IsPostBack Then DataBind() End If Quote "If someone say : "Die mortal !"... don't stay to see if he isn't." - Unknown "Learning to program is like going out with a new girl friend. There's always something that wasn't mentioned in the documentation..." - Me "A drunk girl is like an animal... it scream at everything like a cat and roll in the grass like a dog." - Me after seeing my girlfriend drunk and some of her drunk friend. C# TO VB TRANSLATOR
doraemon Posted April 6, 2004 Author Posted April 6, 2004 No, I did not. Because if I did, the code would not even run. Did you put your DataBind in a condition like this ? If Not Me.IsPostBack Then DataBind() End If Quote
Arch4ngel Posted April 6, 2004 Posted April 6, 2004 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) Quote "If someone say : "Die mortal !"... don't stay to see if he isn't." - Unknown "Learning to program is like going out with a new girl friend. There's always something that wasn't mentioned in the documentation..." - Me "A drunk girl is like an animal... it scream at everything like a cat and roll in the grass like a dog." - Me after seeing my girlfriend drunk and some of her drunk friend. C# TO VB TRANSLATOR
doraemon Posted April 6, 2004 Author Posted April 6, 2004 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? 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) Quote
Administrators PlausiblyDamp Posted April 6, 2004 Administrators Posted April 6, 2004 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. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Moderators Robby Posted April 6, 2004 Moderators Posted April 6, 2004 Are you filtering it with a Where clause in your Select statement? If so, WHY? If not then follow Arch4's suggestion. Quote Visit...Bassic Software
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.