ASP.NET
ObjectDataSource ¿Ø¼þ»ùÓÚ SelectMethod¡¢InsertMethod¡¢UpdateMethod »ò DeleteMethod ÊôÐÔÖÐËù±êʶµÄ·½·¨Ãû³ÆÒÔ¼°×é³ÉÒµÎñ¶ÔÏó·½·¨Ç©ÃûµÄ²ÎÊýÃûÀ´µ÷ÓÃÒµÎñ¶ÔÏó·½·¨¡£ÔÚÒµÎñ¶ÔÏóÖд´½¨·½·¨Ê±£¬±ØÐëÈ·±£ÒµÎñ¶ÔÏó·½·¨Ëù½ÓÊܵIJÎÊýÃûºÍÀàÐÍÓë ObjectDataSource ¿Ø¼þ´«µÝµÄ²ÎÊýÃûºÍÀàÐÍÆ¥Åä¡££¨²ÎÊý˳Ðò²¢²»ÖØÒª¡££©
Ò»¡¢Ê¹ÓòÎÊý
ͬËùÓеÄÊý¾ÝÔ´¿Ø¼þÒ»Ñù£¬ObjectDataSource ¿Ø¼þÔÚÔËÐÐʱ½ÓÊÜÊäÈë²ÎÊý£¬²¢ÔÚ²ÎÊý¼¯ºÏÖжԲÎÊý½øÐйÜÀí¡£Ã¿Ò»ÏîÊý¾Ý²Ù×÷¶¼ÓÐÒ»¸öÏà¹ØµÄ²ÎÊý¼¯ºÏ¡£¶ÔÓÚÑ¡Ôñ²Ù×÷£¬¿ÉÒÔʹÓà SelectParameters ¼¯ºÏ£»¶ÔÓÚ¸üвÙ×÷£¬¿ÉÒÔʹÓà UpdateParameters ¼¯ºÏ£¬ÒÀ´ËÀàÍÆ¡£
¿ÉÒÔΪÿ¸ö²ÎÊýÖ¸¶¨Ãû³Æ¡¢ÀàÐÍ¡¢·½ÏòºÍĬÈÏÖµ¡£¶ÔÓÚ´ÓÌض¨¶ÔÏó£¨ÀýÈ磬¿Ø¼þ¡¢»á»°±äÁ¿»òÓû§ÅäÖÃÎļþ£©»ñÈ¡ÖµµÄ²ÎÊý£¬ÐèÒªÉèÖÃÆäËûÊôÐÔ¡£ÀýÈ磬¶ÔÓÚ ControlParameter ¶ÔÏó£¬ÐèÒªÉèÖà ControlID ÊôÐÔÒÔ±êʶҪ»ñÈ¡²ÎÊýÖµµÄ¿Ø¼þ£¬ÒÔ¼°ÉèÖà PropertyName ÊôÐÔÒÔ±êʶ°üº¬²ÎÊýÖµµÄÊôÐÔ¡£
ÏÂÃæµÄ´úÂëʾÀýÑÝʾһ¸ö¿ÉÒÔͨ¹ý ObjectDataSource ¿Ø¼þµ÷ÓÃµÄ Select ·½·¨¡£¸Ã·½·¨´ÓÊý¾ÝÔ´»ñÈ¡²ÎÊý²¢Ñ¡Ôñµ¥¸ö¼Ç¼¡£
[DataObjectMethod(DataObjectMethodType.Select)]
public static DataTable GetEmployee(int EmployeeID)
{
if (!_initialized) { Initialize(); }
SqlConnection conn = new SqlConnection(_connectionString);
SqlDataAdapter da =
new SqlDataAdapter("SELECT EmployeeID, LastName, FirstName, Address, City, Region, PostalCode from Employees WHERE EmployeeID = @EmployeeID", conn);
da.SelectCommand.Parameters.Add("@EmployeeID", SqlDbType.Int).Value = EmployeeID;
DataSet ds = new DataSet();
try
{
conn.Open();
da.Fill(ds, "Employees");
}
catch (SqlException e)
{
// Handle exception.
}
finally
{
conn.Close();
}
if (ds.Tables["Employees"] != null)
return ds.Tables["Employees"];
return null;
}
¶þ¡¢Îª Insert¡¢Update ºÍ Delete ·½·¨´«µÝ²ÎÊý
ObjectDataSource ¿Ø¼þ»ùÓÚ
Ïà¹ØÎĵµ£º
ÖÚËùÖÜÖªASP.NET 2.0Àï¶Ô±¾µØ»¯£¨Localization£©×öÁ˺ܶ๤×÷£¬´ó´ó¼ò»¯ÁË¿ª·¢¹ý³Ì¡£½ñÌìÖÕÓÚÄܳé³öʱ¼äÑо¿Ò»ÏÂÕâ¸ö¼¼ÊõÁË£¬×ÊÁϺܶ࣬µ«´ó¶à´ø×ÅÒ»¹ÉÒ§ÎĽÀ×ֵķÒëζµÀ£¬So......×Ô¼ºÐ´Ò»Æª¡£
1.ʹÓù¤¾ß×Ô¶¯Éú³É±¾µØ»¯×ÊÔ´£¨LocalResources£©
2.ÔÀ´Localizable AttributePropertyÊÇÕâô»ØÊÂѽ
3.ÊÖ¹¤Ìí¼Ó±¾µ ......
Õâ¸öÓкܶàÖÖ·½·¨ÎÒÔÚÕâÀïд¼¸¸ö°É
·½Ê½Ò»£º
ÔÚÒ³ÃæµÄPreInitʼþÖÐÖ±½ÓÉèÖ᣸÷½·¨¿ÉʵÏÖ²»Í¬Ò³Ãæ¼ÓÔز»Í¬Ö÷Ì⣬Èç¹ûҪʵÏÖÍøÕ¾ÕûÌå»»·ô£¬Ö»ÐèÒª´´½¨Ò»¸ö´ÓSystem.Web.UI.PageÀàÅÉÉúµÄ×ÓÀ࣬ÔÚ¸ÃÀàµÄPreInitʼþÖмÓÔØÌض¨Ö÷Ì⣬×îºóËùÓÐÒ³Ãæ¼Ì³Ð×Ô´ËÀ༴¿É¡£
protected override void OnPreInit(Event ......
ASP.NET´´ÉèWeb·þÎñÖÎÀíWeb·þÎñ״̬
2009-ËÄ-21
XML Web·þÎñÔÚÖÖ¶ÒÏÖÑÜÉúÓÚWebServiceÖÖµÄXML Web·þÎñʱ£¬¿ÉÒÔÔËÓúÍÆäÓàASP.NETÓ¦ÓóÌÐòÀ×ͬµÄ״̬ÖÎÀíÑ¡Ïî¡£WebServiceÖÖ°üÔкö๫¹²ASP.NET¶ÔÏ󣬰üÀ¨SessionºÍApplication¶ÔÏó¡£
Application¶ÔÏóÌṩһ¸ö´æ´¢ÔË×÷ÔÚWebÓ¦ÓóÌÐòÖеĴúÂë¿É·ÃÎʵÄÊý¾ÝµÄ»úÖÆ£¬¶øS ......
ÔÚGlobal.asaxÆô¶¯Ò»ÌõÏ߳̾ÍokÁË£¬ÏÂÃæÊÇÆô¶¯Ï̶߳¨Ê±Ð´ÎļþµÄÀý×Ó
¡¡¡¡Global.asax
¡¡¡¡C# code
¡¡¡¡Code
¡¡¡¡1<%@ Application Language="C#" %>
¡¡¡¡2<%@ Import Namespace="System.IO" %>
¡¡¡¡3<%@ Import Namespace="System.Threading" %>
¡¡¡¡4<script runat="server">
¡¡¡¡5 ......
ÔÚ¡¶ASP.NET¿ª·¢£ºÔÚÓû§¿Ø¼þÖÐÌí¼ÓÊôÐÔ¡·ÕâһƪÎÄÕÂÖÐÎÒÃǶ¨ÒåÁËÒ»¸öÓû§µÇ¼µÄÓû§¿Ø¼þUserLogin.ascx Îļþ£¬ÀïÃæ°üº¬ÁËÒ»¸öLinkButton·þÎñÆ÷°´Å¥¿Ø¼þ£¬µ±Óû§µ¥»÷¸Ã°´Å¥Ê±·þÎñÆ÷¶Ë»á×Ô¶¯Éú³ÉÒ»¸ö»Ø·¢À´¼¤·¢Page.Loadʼþ¡£³ýÁË·þÎñÆ÷×Ô¶¯²úÉú»Ø·¢À´¼¤·¢Page.LoadʼþÍ⣬ÎÒÃÇ¿ÉÒÔ¸øLinkButtonÌí¼ÓÒ»¸öËü×Ô¼ºµÄʼþ ......