ASP.NETÖеÄEval£¨£©ºÍDataBinder.Eval£¨£©·½·¨
ASP.NETÖеÄEval£¨£©ºÍDataBinder.Eval£¨£©·½·¨
2009-12-12 17:55
Eval( " ")ºÍBind( " ")¡¡ÕâÁ½ÖÖÒ»¸öµ¥Ïò°ó¶¨£¬Ò»¸öË«Ïò°ó¶¨
bindÊÇË«Ïò°ó¶¨,µ«ÐèÊý¾ÝÔ´¿É¸ü¸Ä²ÅÄÜÓÃ
ASP.NET 2.0¸ÄÉÆÁËÄ£°åÖеÄÊý¾Ý°ó¶¨²Ù×÷£¬°Ñv1.xÖеÄÊý¾Ý°ó¶¨Óï·¨DataBinder.Eval(Container.DataItem, fieldname)¼ò»¯ÎªEval(fieldname)¡£Eval·½·¨ÓëDataBinder.EvalÒ»Ñù¿ÉÒÔ½ÓÊÜÒ»¸ö¿ÉÑ¡µÄ¸ñʽ»¯×Ö·û´®²ÎÊý¡£Ëõ¶ÌµÄEvalÓï·¨ÓëDataBinder.EvalµÄ²»Í¬µãÔÚÓÚ£¬Eval»á¸ù¾Ý×î½üµÄÈÝÆ÷¶ÔÏó£¨ÀýÈçDataListItem£©µÄDataItemÊôÐÔÀ´×Ô¶¯µØ½âÎö×ֶΣ¬¶øDataBinder.EvalÐèҪʹÓòÎÊýÀ´Ö¸¶¨ÈÝÆ÷¡£ÓÉÓÚÕâ¸öÔÒò£¬EvalÖ»ÄÜÔÚÊý¾Ý°ó¶¨¿Ø¼þµÄÄ£°åÖÐʹÓ㬶ø²»ÄÜÓÃÓÚPage£¨Ò³Ã棩²ã¡£µ±È»£¬ASP.NET 2.0Ò³ÃæÖÐÈÔȻ֧³ÖDataBinder.Eval£¬Äã¿ÉÒÔÔÚ²»Ö§³Ö¼ò»¯µÄEvalÓï·¨µÄ»·¾³ÖÐʹÓÃËü¡£ ÏÂÃæµÄÀý×ÓÑÝʾÁËÈçºÎʹÓÃеļò»¯µÄEvalÊý¾Ý°ó¶¨Óï·¨°ó¶¨µ½DataListÊý¾ÝÏîÄ£°å£¨ItemTemplate£©ÖеÄImage¡¢LabelºÍHyperLink¿Ø¼þ¡£ £¼asp:DataList ID= "DataList1 " RepeatColumns= "5 " Width= "600 " runat= "server " DataSourceID= "ObjectDataSource1 "£¾ ¡¡£¼ItemTemplate£¾ ¡¡¡¡£¼asp:HyperLink ID= "HyperLink1 " runat= "server " NavigateUrl= '£¼%# Eval( "PhotoID ", "PhotoFormViewPlain.aspx?ID={0} ") %£¾ '£¾ ¡¡¡¡£¼asp:Image ID= "Image1 " Runat= "server " ImageUrl= '£¼%# Eval( "FileName ", "images/thumbs/{0} ") %£¾ ' /£¾£¼/asp:HyperLink£¾ ¡¡¡¡£¼asp:Label ID= "CaptionLabel " runat= "server " Text= '£¼%# Eval( "Caption ") %£¾ ' /£¾ ¡¡£¼/ItemTemplate£¾ £¼/asp:DataList£¾£¼br /£¾ £¼asp:ObjectDataSource ID= "ObjectDataSource1 " runat= "server " TypeName= "DataComponentTableAdapters.PhotosTableAdapter " SelectMethod= "GetPhotosForAlbum "£¾ ¡¡¡¡Êý¾Ý°ó¶¨Ò²¿ÉÒÔ×÷Ϊ¿Ø¼þµÄÖ÷ÌⶨÒ壨theme definition£©µÄÒ»²¿·Ö£¬ÕâÑùÎÒÃǾͿÉÒÔͨ¹ý¸Ä±äÖ÷ÌâÀ´ËæÒâµØ¸Ä±äÄ£°å»¯¿Ø¼þµÄ²¼¾ÖºÍÍâ¹Û¡£µ«ÊÇTheme£¨Ö÷Ì⣩ģ°åÖÐÖ»ÄÜʹÓÃEval£¨»òÕߺóÃæÌÖÂÛµÄBind£©¡£°ó¶¨µ½ÈÎÒâµÄÓû§´úÂëÊDZ»½ûÖ¹µÄ¡£
Q:DataBinder.Eval(Container.DataItem,"Name")ºÍContainer.DataItem("Name")ÓÐʲôÇø±ð£¿
A:DataBinderÊÇSystem.WebÀïÃæµÄÒ»¸ö¾²Ì¬À࣬ËüÌṩÁËEval·½·¨ÓÃÓÚ¼ò»¯Êý¾Ý°ó¶¨±í´ïʽµÄ±àд£¬µ«ÊÇËüʹÓõķ½Ê½ÊÇͨ¹ýReflecti
Ïà¹ØÎĵµ£º
+++ ÔÚWebÓ¦ÓóÌÐò¿ª·¢ÖУ¬»º´æ¶ÔÓ¦ÓóÌÐòÐÔÄܵÄÌá¸ßÓкܴó°ïÖú¡£±ÈÈ磬ÔÚͬһ¸öÓ¦ÓÃÖУ¬¾³£·¢Éú¶ÔͬһÊý¾Ý¡¢Âß¼¹¦ÄܺÍÓû§½çÃæµÄ¶à´ÎÇëÇó¡£µ±Óû§µÄ»ùÊýºÜ´óʱ£¬Èç¹ûÿ´ÎµÄÇëÇ󶼽øÐд¦Àí£¬Ôò»áÏûºÄºÜ¶àµÄ·þÎñÆ÷×ÊÔ´¡£ÁíÍ⣬ÓÐʱ·þÎñÆ÷ÌṩµÄÊý¾Ý·þÎñ¿ÉÄÜ»áÒâÍâµØÍ£Ö¹£¬Ê¹Óûº´æ¼¼Êõ¿ÉÒÔÔÚÒ»¶¨Ê±¼äÄÚÈÔÈ»Õý³£µØÌṩ¶Ô×îÖ ......
+++ Ò³Ãæ´úÂëÈçÏ£º
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True" PageSize="3"
AutoGenerateColumns="true" DataKeyNames="username" DataSourceID="SqlDataSource1"
AutoGenerateDeleteButton="True"
AutoGen ......
1.GSC_WebControlLibrary ÕâÊÇÔÚÍøÉÏÕÒµ½µÄÒ»¸ö¿Ø¼þ£¬·Ç³£ºÃÓᣵ«ÊÇЧ¹û²»ÊÇÌرðºÃ£¨¼ûÏÂͼ¡£
£©ËäÈ»ÈÝÒ×ʹÓã¬ËùÓеÄÊôÐÔ¶¼¿ÉÒÔÏñ¿Ø¼þÒ»ÑùÉèÖ㬵«ÊÇ¿ÉÓÃÐÔ²»Ì«¸ß¡£Óû§²»ÄÜ×Ô¶¨Ò壬¶øÇÒ¿´ÆðÀ´Õâ¸öÑéÖ¤ÂëЧ¹û²»Ì«ºÃ¡£
Ч¹û£º
2.ÓÃÒ»¸öÒ³ÃæÉú³ÉͼƬ£¬ÁíÒ»¸öÒ³Ãæµ÷Óã¬ÑéÖ¤Âë´æÈëcookie£¬µ÷ÓÃʱȡcookie ......
1.¹ØÓÚ»º´æ
»º´æÉÏ£¬Êý¾Ý²ãÉϵĻº´æÊDZØÐëµÄ£¬Õâµã²»±Ø¶à˵ÁË¡£
ÁíÒ»¸öºÜÖØÒªµÄÊÇ£ºÊÓͼƬ¶Î»º´æ¡£
ÎҲο¼ÁËÀÏÕÔµÄдµÄÈýƪ¹ØÓÚƬ¶Î»º´æµÄÎÄÕ£º
ÊʺÏASP.NET MVCµÄÊÓͼƬ¶Ï»º´æ·½Ê½£¨ÉÏ£©£ºÆð²½
ÊʺÏASP.NET MVCµÄÊÓͼƬ¶Ï»º´æ·½Ê½£¨ÖУ©£º¸üʵÓõÄAPI
ÊʺÏASP.NET MVCµÄÊÓͼƬ¶Ï»º´æ·½Ê½£¨Ï£©£ºÒ³ÃæÊä³öÔÔò
± ......
ʹÓà ConfigurationSettings ¶ÔÏóµÄ AppSettings ÊôÐÔ¼ìË÷ ASP.NET ÅäÖÃÐÅÏ¢¡£
ASP.NET ÔÊÐí¿ª·¢ÈËԱͨ¹ýÖ±½Ó¹«¿ªÅäÖÃÉèÖã¨ÒÔÇ¿ÀàÐÍÊôÐÔµÄÐÎʽ£©»òʹÓó£¹æÅäÖà API£¬´ÓÓ¦ÓóÌÐòÖзÃÎÊÅäÖÃÉèÖá£Ï ......