开发者

Should I use a ListView for single-row data?

I use Asp.net 4 and C#.

I'm developing a simple CMS, at the moment I want to displays the content for a specific PAGE (Title, BodyContent, and some other fields) at the end user on a web page (like as this website display its questions to its Users).

I need wrap my fields from database in appropriate HTML TAGS example <h1>Title</h1> <div>BodyContent</div>.

The resulting page should be READ ONLY .

I would like to know:

  1. If a ListView web control with setting for a single row would be the right choice (maybe binded with ObjectDataSource).
  2. If would be better use separate Web Controls like Literals or Labels to displays my f开发者_开发问答ields sparsely on my webpage
  3. In case of previous point how would I DataBind every single Control? Using different DataBinder or maybe with Linq an projecting using Anonymous Type.

I'm mainly concerned with read-only performance.


If you have data that's a single row, there's not much point in using a ListView. They're designed for showing lists of data (hence the name). If you have one item, consider either a DetailsView or single Labels.

If you have a particular class that often needs to be displayed in a certain way, consider setting up a Web User Control that can be bound to instances of that class.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜