开发者

Should I use a ListView for single-row data?

开发者 https://www.devze.com 2023-03-28 00:17 出处:网络
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

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

精彩评论

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