k-dev
k-dev

Reputation: 1657

how to add items to Asp.Net ListView webcontrol

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.

Upvotes: 0

Views: 3303

Answers (1)

Brian Mains
Brian Mains

Reputation: 50728

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.

Upvotes: 1

Related Questions