0

I have a ListView control in Asp.Net WebForms which display a set of elements, I have at the end a "More" button like Facebook for example. During the postback I want to get from database another 10 elements (I have already displayed 10 and I don't want to retrieve them again)

Something like this.

 foreach (var item in New10Items)
     ListView.Items.Add(index,DataItem)

the problem is with DataItem, how to Bind it before add it? what is the best way of solving this?

I don't want to store first 10 items on session or retrieve them from database again because is Really!!! bad for performance and memory, they are no so simple.

if you don't understand please ask, I really need a way to solve this as clean as possible.

0

1 Answer 1

1

Facebook though makes a REST service call and appends them using JavaScript. I'd recommend that if you could call a web service and append additional items to the HTML generated from the ListView, that would be a very efficient way. Otherwise, you're going to have to postback and rebind data or store it in session for the original data. That's how the control was designed to work.

HTH.

Sign up to request clarification or add additional context in comments.

3 Comments

Well, it is really a pain, these are the kind of things that make me think in Asp.Net MVC for next project, WebForms have a terrible support for this.
ASP.NET MVC doesn't have viewstate, so if you are going to the server, you definitely have to rebind, but yes MVC has more offerings with its AJAX natively.
@k-dev, you can still do the same thing in WebForms, just create an ashx handler or a page method to return your 10 results and make an ajax call to this method. You can then use JavaScript to append the result without needing to do a PostBack.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.