Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

Posted

Did you put your DataBind in a condition like this ?

If Not Me.IsPostBack Then
  DataBind()
End If

"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

Posted

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

Posted

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)

"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

Posted

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)

  • Administrators
Posted

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.

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...