ASP.netÖÐlistview¿Ø¼þÓ÷¨
ListView »ù´¡
ListView ÊÇÄ£°åÇý¶¯µÄ¿Ø¼þ£¬ÕâÒâζ×ÅËüĬÈÏÇé¿öϲ»»á³ÊÏÖÈκÎÊý¾Ý——Äú±ØÐëÒÔÄ£°åµÄÐÎʽÍêÈ«Ö¸¶¨Ï£ÍûËü³ÊÏÖµÄ HTML¡£Óë´ó¶àÊýÄ£°å¿Ø¼þÀàËÆ£¬ItemTemplate ½«³ÉΪÄú¹¤×÷µÄÖص㣬ÄúÐèÒª½«°ó¶¨Êý¾Ý¼¯ÖÐÿһÐ⻶ÏÖظ´µÄ HTML ÄÚÈÝ·ÅÔÚ ItemTemplate Àï¡£
ListView ÖеÄй¦ÄÜ£¬Ò²ÊÇËüÓëÆäËü¿Ø¼þµÄÕæÕý²»Í¬Ö®´¦ÔÚÓÚÒý½øÁË LayoutTemplate¡£ÔÚ LayoutTemplate ÖУ¬Äú¿ÉÒÔ½«ÒªÊä³öµÄ¶¥¼¶ HTML ¶¨ÒåΪ¿Ø¼þ³ÊÏÖµÄÄÚÈÝ¡£ÀýÈ磬Èç¹ûÏ£Íû ListView ×÷Ϊ±í¸ñ³ÊÏÖ£¬Ôò¿ÉÒÔÔÚ LayoutTemplate Öаüº¬¶¥¼¶ <table> ºÍ <thead> ÔªËØ£¬°ÑÐк͵¥Ôª¸ñµÄ³ÊÏÖÁô¸ø ItemTemplate£¬Èçͼ 1 Ëùʾ£¨ÔÚ±¾Ê¾ÀýÖУ¬°ó¶¨µÄÊý¾ÝÔ´½«ÏÔʾ°üº¬µçÓ°±êÌâºÍ·¢ÐÐÈÕÆڵļòµ¥±í¸ñ£©¡£Í¼ 2 ÏÔʾÁËä¯ÀÀÆ÷³ÊÏÖ¡£
Figure 1 Using LayoutTemplate and ItemTemplate
¸´ÖÆ´úÂë
<asp:ListView runat="server" ID="_simpleTableListView"
DataSourceID="_moviesDataSource">
<LayoutTemplate>
<table>
<thead>
<tr>
<th>ID</th>
<th>Title</th>
<th>Release Date</th>
</tr>
</thead>
<tbody>
<asp:PlaceHolder runat="server" ID="itemPlaceholder" />
</tbody>
</table>
</LayoutTemplate>
<ItemTemplate>
<tr>
<td><%# Eval("movie_id") %></td>
<td><%# Eval("title") %></td>
<td><%# Eval("release_date", "{0:d}") %></td>
</tr>
</ItemTemplate>
</asp:ListView>
Figure 2 ÏÔʾÔÚ±í¸ñÖеÄÁбí (µ¥»÷¸ÃͼÏñ»ñµÃ½Ï´óÊÓͼ)
LayoutTemplate ºÍ ItemTemplate Ö®¼äµÄ¹ØÁªÓÉ LayoutTemplate ÖÐ ID ÉèÖÃΪ itemPlaceholder µÄµ¥Ò»·þÎñÆ÷¶Ë¿Ø¼þÍê³É¡££¨Äú¿ÉÒÔʹÓà ListView µÄ ItemPlaceholderID ÊôÐÔ¸ü¸Ä ID ×Ö·û´®µÄĬÈÏÖµ¡££©ÔÚµÚÒ»¸öʾÀýÖУ¬ÎÒ½« PlaceHolder ¿Ø¼þµÄʵÀý·ÅÖÃÔÚÄ£°åÖУ¬¼´ÎÒÏ£Íû×¢Èë ItemTemplate ÄÚÈݵÄλÖá£Çë×¢Ò⣺¾¡¹Ü±ØÐëÖ§³Ö×ӿؼþ£¬µ«²¢Ã»ÓÐÏÞÖƱØÐëʹÓÃʲôÀàÐ͵Ŀؼþ×÷Ϊռλ·û——ID ²ÅÊÇÖØÒª¡£ÀýÈ磬ÎÒ¿ÉÒÔʹÓ÷þÎñÆ÷
Ïà¹ØÎĵµ£º
ÔÚWeb±à³Ì¹ý³ÌÖУ¬´æÔÚןܶలȫÒþ»¼¡£±ÈÈçÔÚÒÔÇ°µÄASP°æ±¾ÖУ¬CookieΪ·ÃÎÊÕߺͱà³ÌÕ߶¼ÌṩÁË·½±ã£¬²¢Ã»ÓÐÌṩ¼ÓÃܵŦÄÜ¡£´ò¿ªIEä¯ÀÀÆ÷£¬Ñ¡Ôñ“¹¤¾ß”²Ëµ¥ÀïµÄ“InternetÑ¡Ï¬È»ºóÔÚµ¯³öµÄ¶Ô»°¿òÀïµ¥»÷“ÉèÖÔ°´Å¥£¬Ñ¡Ôñ“²é¿´Îļþ”°´Å¥£¬ÔÚµ¯³öµÄ´°¿ÚÖУ¬¾Í»áÏÔʾӲÅÌÀï ......
ÏÖÔÚÄ£ÄâÔÚA·þÎñÆ÷ÉÏ·ÃÎÊB·þÎñÆ÷DÅÌϵÄÒ»¸öÎļþ test.txt
1 ÔÚA·þÎñÆ÷ web.config µÄ<system.web>ϼÓÈë<identity impersonate="true" userName="duzhe123.com" password="boosou.com"/>
2 Á½Ì¨·þÎñÆ÷É϶¼½¨Á¢Ò»¸öÕʺŠduzhe123.com£¬ÃÜÂëΪ boosou.com ¡£ºÇºÇ£¬ÕÊºÅºÍ ......
»ñÈ¡ÇëÇóµÄÒ³µÄHttpApplicationState ¶ÔÏó¡£
Ò»¡¢HttpApplicationState Àà
×÷ÓãºÆôÓà ASP.NET Ó¦ÓóÌÐòÖжà¸ö»á»°ºÍÇëÇóÖ®¼äµÄÈ«¾ÖÐÅÏ¢¹²Ïí¡£
ASP.NET Ó¦ÓóÌÐòµÄ¸ÅÄÊǵ¥¸ö Web ·þÎñÆ÷ÉϵÄij¸öÐéÄâĿ¼¼°Æä×ÓĿ¼·¶Î§ÄÚµÄËùÓÐÎļþ¡¢Ò³¡ ......
12 ASP.NET MVC Best Practices
M
DomainModel != ViewModel
Use ActionFilters for “shared” data
V
Do NEVER user code-behind
Write HTML each time you can
If there is an if, write an HtmlHelper
Choose your view engine carefully
C
Delete the AccountController
Isolate Controllers fro ......
asp.net¶àƵµÀÍøÕ¾¿ª·¢¼Ü¹¹Ç³Îö http://www.cnblogs.com/Kenny-Jiang/archive/2007/07/31/837900.html ±³¾°£º
ÎÒÃÇ´ò¿ªÃÅ»§Íøվʱ£¬ÍùÍù»á¿´µ½ºÜ¶àÅÅÁнôÃܵÄƵµÀÁÐ±í£¬Èç¡°ÐÂÎÅ¡±¡¢¡°²Æ¾¡±¡¢¡°ÓéÀÖ¡±µÈ¡£ÆµµÀΪÍøÕ¾ÌṩÁË·½±ãµÄµ¼º½¹¦ÄÜ¡£
ÄÚÈÝÃèÊö£º
......