开发者

Divs on an ASP.NET Gridview

The GridView in ASP.NET wh开发者_开发技巧en rendered isn't the prettiest or most semantic control ever, is there a way to use <div> using constructing it? Or should there be another approach, I ideally would like to remain using the gridview because I select the DataKeyNames in my code, unless there is a similar way to select the DataKeyNames using another control like a listview?


+1 to Lareau. ListView has a DataKeyNames property as well. I would use Ingrid (jQuery) along with a ListView control to make it better.

ListView samples:

http://weblogs.asp.net/scottgu/archive/2008/01/04/jan-4th-links-asp-net-asp-net-ajax-asp-net-mvc-visual-studio-iis7.aspx

http://basgun.wordpress.com/2007/12/29/listview-control-in-aspnet-35-3/

https://web.archive.org/web/20211020153238/https://www.4guysfromrolla.com/articles/122607-1.aspx

https://web.archive.org/web/20210125144848/http://www.4guysfromrolla.com/articles/021308-1.aspx

Download and demo Ingrid:

http://www.reconstrukt.com/ingrid/


You can use repeater instead


I would go with a listView. Similar to a repeater but just a bit better.


The GridView is tabular data. It uses a table to construct it. It's perfectly semantic. I agree it isn't pretty, but a <div> construction of tabular data is just as ugly. The GridView has the greatest functionality for this kind of data display/management.


You might be able to customize the rendering by overriding the Render method of GridView control. This would mean that you are changing the default behaviour of GridView and might need to handle additional events if you decide to do change defaults.


Instead of using the semantics of a div, I would look to format the class using some tailored CSS. Let me know if this is something you're interested in and I can offer you some links.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜