Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

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 ²ÅÊÇÖØÒª¡£ÀýÈ磬ÎÒ¿ÉÒÔʹÓ÷þÎñÆ÷


Ïà¹ØÎĵµ£º

ASP.NETÒ³Ãæ¶ÔÏó

 Ò»¡¢Page Àà
      Page ÀàÓëÀ©Õ¹ÃûΪ .aspx µÄÎļþÏà¹ØÁª£»ÕâЩÎļþÔÚÔËÐÐʱ±»±àÒëΪ Page ¶ÔÏ󣬲¢±»»º´æÔÚ·þÎñÆ÷ÄÚ´æÖС£Èç¹ûÊÇʹÓôúÂëÒþ²Ø¼¼Êõ´´½¨ Web ´°ÌåÒ³£¬Çë´Ó¸ÃÀàÅÉÉú¡£
Àý£º£¨public partial class _Default : System.Web.UI.Page£©
      Page ¶ ......

ASP.NETÒ³Ãæ¶ÔÏó

   »ñÈ¡ÇëÇóµÄÒ³µÄHttpApplicationState ¶ÔÏó¡£
Ò»¡¢HttpApplicationState Àà
      ×÷ÓãºÆôÓà ASP.NET Ó¦ÓóÌÐòÖжà¸ö»á»°ºÍÇëÇóÖ®¼äµÄÈ«¾ÖÐÅÏ¢¹²Ïí¡£
      ASP.NET Ó¦ÓóÌÐòµÄ¸ÅÄÊǵ¥¸ö Web ·þÎñÆ÷ÉϵÄij¸öÐéÄâĿ¼¼°Æä×ÓĿ¼·¶Î§ÄÚµÄËùÓÐÎļþ¡¢Ò³¡ ......

asp.netÖÐapp_codeºÍbinÎļþ¼Ð½éÉÜ

       Èç¹ûÄúµÄ Web Ó¦ÓóÌÐò°üÀ¨ÒªÔÚ¶à¸öÒ³Ö®¼ä¹²ÏíµÄ´úÂ룬Äú¿ÉÒÔ½«´úÂë±£´æÔÚ Web Ó¦ÓóÌÐò¸ùĿ¼ÏµÄÁ½¸öÌØÊâÎļþ¼Ð£¨Bin Îļþ¼ÐºÍ App_Code Îļþ¼Ð£©ÖеÄij¸öÎļþ¼ÐÖС£
Bin Îļþ¼Ð
      ¿ÉÒÔÔÚ Bin Îļþ¼ÐÖд洢±àÒëµÄ³ÌÐò¼¯£¬²¢ÇÒ Web Ó¦ÓóÌÐòÈÎÒâ´¦µ ......

Ñ­»·ÎªTextBox¸³Öµ (asp.net C#)

 ×¢Òâ:
ÔÚʹÓÃFindControlʱ,Ò»¶¨ÒªÔÚ×îÌù½ü²éÕÒ¶ÔÏóµÄÍâ±ß¼ÓÉϸöÈÝÆ÷,Èç¹ûÄãÖ±½ÓÓÃthis.FindControl,»òPage.FindControlÄÇô¾Í»á¾­³£³öÏÖ佫¶ÔÏóÉèÖõ½ÊµÀý
µÄ´íÎó,ËùÒÔ×îºÃ¼ÓÒ»¸öÈÝÆ÷,ÄÇôÕâÀï¼ÓµÄDIV¾ÍÊÇÒ»¸öÈÝÆ÷,ΪÁËÈÃFindControlÔÚIDΪ"TextBoxs"µÄDIVÄÚÈ¥ÕÒÃûΪcom1,com2,com3µÄTextBOx;
<div ......

ASP.NETÒ³Ãæˢз½·¨×ܽá

ÏÈ¿´¿´ASP.NETÒ³ÃæˢеÄʵÏÖ·½·¨£º
µÚÒ»£º
private void Button1_Click( object sender, System.EventArgs e ) { Response.Redirect( Request.Url.ToString( ) ); } µÚ¶þ£º
private void Button2_Click( object sender, System.EventArgs e ) { Response.Write( " < script language=javascript>window.locatio ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ