飘灵儿 发表于 2015-1-16 22:48:41

ASP.NET网页编程之ASP.NET2.0进修5--N层代码示例

那做企业软件是不是最好用J2EE?asp.net|示例1、数据库Test,
表:createtableCustomers
(
CustIdintIDENTITY(1,1)primarykey,
CustNamevarchar(20)notnull,
Addressvarchar(50),
Linkmanvarchar(20)
)
//insertintoCusomersvalues(ggg,xuzhou,zhangsan);
2、设置文件web.config
<?xmlversion="1.0"?>
<configuration>
<appSettings/>
<connectionStrings>
<addname="TestConnectionString"connectionString="DataSource=GONGCHL;InitialCatalog=Test;PersistSecurityInfo=True;UserID=sa;Password=123"providerName="System.Data.SqlClient"/>
</connectionStrings>
<system.web>
<compilationdebug="true"/>
<authenticationmode="Windows"/>
</system.web>
</configuration>
3、营业实体
usingSystem;
usingSystem.Collections.Generic;
usingSystem.Text;
namespacecom.Model
{
///<summary>
///营业实体CustomerInfo
///</summary>

publicclassCustomerInfo
{
///<summary>
///默许的机关函数
///</summary>
publicCustomerInfo(){}
///<summary>
///有参数的机关函数
///</summary>
///<paramname="custId">客户号</param>
///<paramname="custName">客户称号</param>
///<paramname="address">客户地点</param>
///<paramname="linkman">接洽人</param>
publicCustomerInfo(intcustId,stringcustName,stringaddress,stringlinkman)
{
this.custId=custId;
this.custName=custName;
this.address=address;
this.linkman=linkman;
}
privateintcustId;
publicintCustId
{
get{returncustId;}
set{custId=value;}
}
privatestringcustName;
publicstringCustName
{
get{returncustName;}
set{custName=value;}
}
privatestringaddress;
publicstringAddress
{
get{returnaddress;}
set{address=value;}
}
privatestringlinkman;
publicstringLinkman
{
get{returnlinkman;}
set{linkman=value;}
}
}
}
4、数据会见层
类:SqlHelper
//===============================================================================
//.NET数据会见通用程序,来自Microsoft公司
//更多信息拜见
//http://msdn.microsoft.com/library/en-us/dnbda/html/daab-rm.asp
//===============================================================================
usingSystem;
usingSystem.Configuration;
usingSystem.Data;
usingSystem.Data.SqlClient;
usingSystem.Collections;
namespacecom.DataAccess
{
///<summary>
///SqlHelper类供应很高的数据会见功能,
///利用SqlClient类的通用界说.
///</summary>
publicabstractclassSqlHelper
{
//界说数据库毗连串
publicstaticreadonlystringConnectionStringLocalTransaction=ConfigurationManager.ConnectionStrings["TestConnectionString"].ConnectionString;
//publicstaticreadonlystringConnectionStringInventoryDistributedTransaction=ConfigurationManager.ConnectionStrings["SQLConnString2"].ConnectionString;
//publicstaticreadonlystringConnectionStringOrderDistributedTransaction=ConfigurationManager.ConnectionStrings["SQLConnString3"].ConnectionString;
//publicstaticreadonlystringConnectionStringProfile=ConfigurationManager.ConnectionStrings["SQLProfileConnString"].ConnectionString;
//存贮Cache缓存的Hashtable汇合
privatestaticHashtableparmCache=Hashtable.Synchronized(newHashtable());
///<summary>
///利用毗连字符串,实行一个SqlCommand命令(没有纪录前往)
///利用供应的参数集.
///</summary>
///<remarks>
///示例:
///intresult=ExecuteNonQuery(connString,CommandType.StoredProcedure,"PublishOrders",newSqlParameter("@prodid",24));
///</remarks>
///<paramname="connectionString">一个无效的SqlConnection毗连串</param>
///<paramname="commandType">命令范例CommandType(storedprocedure,text,etc.)</param>
///<paramname="commandText">存贮历程称号或是一个T-SQL语句串</param>
///<paramname="commandParameters">实行命令的参数集</param>
///<returns>受此命令影响的行数</returns>
publicstaticintExecuteNonQuery(stringconnectionString,CommandTypecmdType,stringcmdText,paramsSqlParameter[]commandParameters)
{
SqlCommandcmd=newSqlCommand();
using(SqlConnectionconn=newSqlConnection(connectionString))
{
PrepareCommand(cmd,conn,null,cmdType,cmdText,commandParameters);
intval=cmd.ExecuteNonQuery();
cmd.Parameters.Clear();
returnval;
}
}
///<summary>
///在一个存在的毗连上实行数据库的命令操纵
///利用供应的参数集.
///</summary>
///<remarks>
///e.g.:
///intresult=ExecuteNonQuery(connection,CommandType.StoredProcedure,"PublishOrders",newSqlParameter("@prodid",24));
///</remarks>
///<paramname="conn">一个存在的数据库毗连工具</param>
///<paramname="commandType">命令范例CommandType(storedprocedure,text,etc.)</param>
///<paramname="commandText">存贮历程称号或是一个T-SQL语句串</param>
///<paramname="commandParameters">实行命令的参数集</param>
///<returns>受此命令影响的行数</returns>
publicstaticintExecuteNonQuery(SqlConnectionconnection,CommandTypecmdType,stringcmdText,paramsSqlParameter[]commandParameters)
{
SqlCommandcmd=newSqlCommand();
PrepareCommand(cmd,connection,null,cmdType,cmdText,commandParameters);
intval=cmd.ExecuteNonQuery();
cmd.Parameters.Clear();
returnval;
}
///<summary>
///在一个事件的毗连上实行数据库的命令操纵
///利用供应的参数集.
///</summary>
///<remarks>
///e.g.:
///intresult=ExecuteNonQuery(trans,CommandType.StoredProcedure,"PublishOrders",newSqlParameter("@prodid",24));
///</remarks>
///<paramname="trans">一个存在的事件</param>
///<paramname="commandType">命令范例CommandType(storedprocedure,text,etc.)</param>
///<paramname="commandText">存贮历程称号或是一个T-SQL语句串</param>
///<paramname="commandParameters">实行命令的参数集</param>
///<returns>受此命令影响的行数</returns>
publicstaticintExecuteNonQuery(SqlTransactiontrans,CommandTypecmdType,stringcmdText,paramsSqlParameter[]commandParameters)
{
SqlCommandcmd=newSqlCommand();
PrepareCommand(cmd,trans.Connection,trans,cmdType,cmdText,commandParameters);
intval=cmd.ExecuteNonQuery();
cmd.Parameters.Clear();
returnval;
}
///<summary>
///在一个毗连串上实行一个命令,前往一个SqlDataReader工具
///利用供应的参数.
///</summary>
///<remarks>
///e.g.:
///SqlDataReaderr=ExecuteReader(connString,CommandType.StoredProcedure,"PublishOrders",newSqlParameter("@prodid",24));
///</remarks>
///<paramname="connectionString">一个无效的SqlConnection毗连串</param>
///<paramname="commandType">命令范例CommandType(storedprocedure,text,etc.)</param>
///<paramname="commandText">存贮历程称号或是一个T-SQL语句串</param>
///<paramname="commandParameters">实行命令的参数集</param>
///<returns>一个了局集工具SqlDataReader</returns>
publicstaticSqlDataReaderExecuteReader(stringconnectionString,CommandTypecmdType,stringcmdText,paramsSqlParameter[]commandParameters)
{
SqlCommandcmd=newSqlCommand();
SqlConnectionconn=newSqlConnection(connectionString);
//假如不存在要查询的工具,则产生非常
//毗连要封闭
//CommandBehavior.CloseConnection在非常时不产生感化
try
{
PrepareCommand(cmd,conn,null,cmdType,cmdText,commandParameters);
SqlDataReaderrdr=cmd.ExecuteReader(CommandBehavior.CloseConnection);
cmd.Parameters.Clear();
returnrdr;
}
catch
{
conn.Close();
throw;
}
}
///<summary>
///在一个毗连串上实行一个命令,前往表中第一行,第一列的值
///利用供应的参数.
///</summary>
///<remarks>
///e.g.:
///Objectobj=ExecuteScalar(connString,CommandType.StoredProcedure,"PublishOrders",newSqlParameter("@prodid",24));
///</remarks>
///<paramname="connectionString">一个无效的SqlConnection毗连串</param>
///<paramname="commandType">命令范例CommandType(storedprocedure,text,etc.)</param>
///<paramname="commandText">存贮历程称号或是一个T-SQL语句串</param>
///<paramname="commandParameters">实行命令的参数集</param>///<returns>前往的工具,在利用时记得范例转换</returns>
publicstaticobjectExecuteScalar(stringconnectionString,CommandTypecmdType,stringcmdText,paramsSqlParameter[]commandParameters)
{
SqlCommandcmd=newSqlCommand();
using(SqlConnectionconnection=newSqlConnection(connectionString))
{
PrepareCommand(cmd,connection,null,cmdType,cmdText,commandParameters);
objectval=cmd.ExecuteScalar();
cmd.Parameters.Clear();
returnval;
}
}
///<summary>
///在一个毗连上实行一个命令,前往表中第一行,第一列的值
///利用供应的参数.
///</summary>
///<remarks>
///e.g.:
///Objectobj=ExecuteScalar(connString,CommandType.StoredProcedure,"PublishOrders",newSqlParameter("@prodid",24));
///</remarks>
///<paramname="connectionString">一个无效的SqlConnection毗连</param>
///<paramname="commandType">命令范例CommandType(storedprocedure,text,etc.)</param>
///<paramname="commandText">存贮历程称号或是一个T-SQL语句串</param>
///<paramname="commandParameters">实行命令的参数集</param>///<returns>前往的工具,在利用时记得范例转换</returns>
publicstaticobjectExecuteScalar(SqlConnectionconnection,CommandTypecmdType,stringcmdText,paramsSqlParameter[]commandParameters)
{
SqlCommandcmd=newSqlCommand();
PrepareCommand(cmd,connection,null,cmdType,cmdText,commandParameters);
objectval=cmd.ExecuteScalar();
cmd.Parameters.Clear();
returnval;
}
///<summary>
///在缓存中增加参数数组
///</summary>
///<paramname="cacheKey">参数的Key</param>
///<paramname="cmdParms">参数数组</param>
publicstaticvoidCacheParameters(stringcacheKey,paramsSqlParameter[]commandParameters)
{
parmCache=commandParameters;
}
///<summary>
///提取缓存的参数数组
///</summary>
///<paramname="cacheKey">查找缓存的key</param>
///<returns>前往被缓存的参数数组</returns>
publicstaticSqlParameter[]GetCachedParameters(stringcacheKey)
{
SqlParameter[]cachedParms=(SqlParameter[])parmCache;
if(cachedParms==null)
returnnull;
SqlParameter[]clonedParms=newSqlParameter;
for(inti=0,j=cachedParms.Length;i<j;i++)
clonedParms=(SqlParameter)((ICloneable)cachedParms).Clone();
returnclonedParms;
}
///<summary>
///供应一个SqlCommand工具的设置
///</summary>
///<paramname="cmd">SqlCommand工具</param>
///<paramname="conn">SqlConnection工具</param>
///<paramname="trans">SqlTransaction工具</param>
///<paramname="cmdType">CommandType如存贮历程,T-SQL</param>
///<paramname="cmdText">存贮历程名或查询串</param>
///<paramname="cmdParms">命令顶用到的参数集</param>
privatestaticvoidPrepareCommand(SqlCommandcmd,SqlConnectionconn,SqlTransactiontrans,CommandTypecmdType,stringcmdText,SqlParameter[]cmdParms)
{
if(conn.State!=ConnectionState.Open)
conn.Open();
cmd.Connection=conn;
cmd.CommandText=cmdText;
if(trans!=null)
cmd.Transaction=trans;
cmd.CommandType=cmdType;
if(cmdParms!=null)
{
foreach(SqlParameterparmincmdParms)
cmd.Parameters.Add(parm);
}
}
}
}
类:Customer
usingSystem;
usingSystem.Data.SqlClient;
usingSystem.Data;
usingSystem.Text;
usingSystem.Collections.Generic;
usingcom.Model;
namespacecom.DataAccess
{
///<summary>
///对客户表的一切数据会见操纵
///</summary>
publicclassCustomer
{
//静态常量,参数名,T-SQL串
privateconststringSQL_SELECT_CUSTOMER_BY_ID=
"SELECTCustId,CustName,Address,LinkmanFROMCUSTOMERSWHERECustID=@CustId";
privateconststringSQL_SELECT_CUSTOMER_BY_NAME=
"SELECTCustId,CustName,Address,LinkmanFROMCUSTOMERSWHERECustName=@CustName";
privateconststringSQL_SELECT_CUSTOMER_BY_ALL=
"SELECTCustId,CustName,Address,LinkmanFROMCUSTOMERS";
privateconststringSQL_UPDATE_CUSTOMER_BY_ID=
"UPDATECUSTOMERSSETCustName=@CustName,Address=@Address,Linkman=@LinkmanWHERECustId=@CustId";
privateconststringSQL_DELETE_CUSTOMER_BY_ID=
"DELETECUSTOMERSWHERECustId=@CustId";
privateconststringSQL_INSERT_CUSTOMER=
"Declare@IDint;INSERTINTOCUSTOMERSVALUES(@CustName,@Address,@Linkman);SELECT@ID=@@IDENTITY;SELECT@ID";

privateconststringPARM_CUSTOMERID="@CustId";
privateconststringPARM_CUSTOMERNAME="@CustName";
privateconststringPARM_ADDRESS="@Address";
privateconststringPARM_LINKMAN="@Linkman";
///<summary>
///按客户ID查询
///</summary>
///<paramname="custId">客户号</param>
///<returns>客户工具</returns>
publicCustomerInfoGetCustomerById(intcustId)
{
CustomerInfocustomerInfo=null;
SqlParameterparm=newSqlParameter(PARM_CUSTOMERID,SqlDbType.Int);
parm.Value=custId;
//按客户号参数实行查询失掉一个客户信息
using(SqlDataReaderrdr=SqlHelper.ExecuteReader(SqlHelper.ConnectionStringLocalTransaction,CommandType.Text,SQL_SELECT_CUSTOMER_BY_ID,parm))
{
if(rdr.Read())
customerInfo=newCustomerInfo(rdr.GetInt32(0),rdr.GetString(1),rdr.GetString(2),rdr.GetString(3));
}
returncustomerInfo;
}
///<summary>
///按客户称号查询
///</summary>
///<paramname="custName">客户称号</param>
///<returns>客户工具</returns>
publicCustomerInfoGetCustomerByName(stringcustName)
{
CustomerInfocustomerInfo=null;
SqlParameterparm=newSqlParameter(PARM_CUSTOMERNAME,SqlDbType.VarChar,20);
parm.Value=custName;
//按客户号参数实行查询失掉一个客户信息
using(SqlDataReaderrdr=SqlHelper.ExecuteReader(SqlHelper.ConnectionStringLocalTransaction,CommandType.Text,SQL_SELECT_CUSTOMER_BY_NAME,parm))
{
if(rdr.Read())
customerInfo=newCustomerInfo(rdr.GetInt32(0),rdr.GetString(1),rdr.GetString(2),rdr.GetString(3));
}
returncustomerInfo;
}
///<summary>
///查询一切客户信息
///了局为IList
///</summary>
///<returns>一个客户汇合</returns>
publicIList<CustomerInfo>GetCusomersByAll()
{
IList<CustomerInfo>customers=newList<CustomerInfo>();
//Finallyexecutethequery
using(SqlDataReaderrdr=SqlHelper.ExecuteReader(SqlHelper.ConnectionStringLocalTransaction,CommandType.Text,SQL_SELECT_CUSTOMER_BY_ALL,null))
{
while(rdr.Read())
{
CustomerInfocustomerInfo=newCustomerInfo(rdr.GetInt32(0),rdr.GetString(1),rdr.GetString(2),rdr.GetString(3));
customers.Add(customerInfo);
}
}
returncustomers;
}
///<summary>
///拔出一个客户信息
///</summary>
///<paramname="customer">客户工具CustomerInfo</param>
///<returns>bool范例,trueorfalse</returns>
publicboolInsertCustomer(CustomerInfocustomerInfo)
{
SqlParameter[]paras=newSqlParameter;
paras=newSqlParameter(PARM_CUSTOMERNAME,SqlDbType.VarChar,20);
paras.Value=customerInfo.CustName;
paras=newSqlParameter(PARM_ADDRESS,SqlDbType.VarChar,50);
paras.Value=customerInfo.Address;
paras=newSqlParameter(PARM_LINKMAN,SqlDbType.VarChar,20);
paras.Value=customerInfo.Linkman;
using(SqlDataReaderrdr=SqlHelper.ExecuteReader(SqlHelper.ConnectionStringLocalTransaction,CommandType.Text,SQL_INSERT_CUSTOMER,paras))
{
if(rdr.Read())
customerInfo.CustId=rdr.GetInt32(0);
else
returnfalse;
}
returntrue;
}
///<summary>
///修正一个客户信息
///</summary>
///<paramname="customer">客户工具CustomerInfo</param>
///<returns>bool范例,trueorfalse</returns>
publicboolUpdateCustomerByID(CustomerInfocustomerInfo)
{
SqlParameter[]paras=newSqlParameter;
paras=newSqlParameter(PARM_CUSTOMERNAME,SqlDbType.VarChar,20);
paras.Value=customerInfo.CustName;
paras=newSqlParameter(PARM_ADDRESS,SqlDbType.VarChar,50);
paras.Value=customerInfo.Address;
paras=newSqlParameter(PARM_LINKMAN,SqlDbType.VarChar,20);
paras.Value=customerInfo.Linkman;
paras=newSqlParameter(PARM_CUSTOMERID,SqlDbType.Int);
paras.Value=customerInfo.CustId;
introw=SqlHelper.ExecuteNonQuery(SqlHelper.ConnectionStringLocalTransaction,CommandType.Text,SQL_UPDATE_CUSTOMER_BY_ID,paras);
if(row==0)
returnfalse;
returntrue;
}
///<summary>
///按ID删除一个客户信息
///</summary>
///<paramname="custId">客户号</param>
///<returns>bool范例,trueorfalse</returns>
publicboolDeleteCustomerByID(intcustId)
{
SqlParameterpara=newSqlParameter(PARM_CUSTOMERID,SqlDbType.Int);
para.Value=custId;
introw=SqlHelper.ExecuteNonQuery(SqlHelper.ConnectionStringLocalTransaction,CommandType.Text,SQL_DELETE_CUSTOMER_BY_ID,para);
if(row==0)
returnfalse;
returntrue;
}
}
}
5、营业逻辑层
usingSystem;
usingSystem.Collections.Generic;
usingSystem.Text;
usingcom.DataAccess;
usingcom.Model;
usingcom.BusinessRule;
namespacecom.BusinessLogic
{
publicclassCustomerLogic
{
///<summary>
///拔出一个客户信息
///</summary>
///<paramname="custId">客户号</param>
///<paramname="custName">客户称号</param>
///<paramname="address">客户地点</param>
///<paramname="linkman">接洽人</param>
///<returns>bool范例,trueorfalse</returns>
publicboolInsertCustomer(intcustId,stringcustName,stringaddress,stringlinkman)
{
if(CustomerRule.IsExistCustomerName(custName))
returnfalse;
Customercustomer=newCustomer();
CustomerInfocustomerInfo=newCustomerInfo(custId,custName,address,linkman);
returncustomer.InsertCustomer(customerInfo);
}
///<summary>
///拔出一个客户信息
///</summary>
///<paramname="custName">客户称号</param>
///<paramname="address">客户地点</param>
///<paramname="linkman">接洽人</param>
///<returns>bool范例,trueorfalse</returns>
publicboolInsertCustomer(stringcustName,stringaddress,stringlinkman)
{
if(CustomerRule.IsExistCustomerName(custName))
returnfalse;
Customercustomer=newCustomer();
CustomerInfocustomerInfo=newCustomerInfo(0,custName,address,linkman);
returncustomer.InsertCustomer(customerInfo);
}
///<summary>
///修正一个客户信息
///</summary>
///<paramname="custId">客户号</param>
///<paramname="custName">客户称号</param>
///<paramname="address">客户地点</param>
///<paramname="linkman">接洽人</param>
///<returns>bool范例,trueorfalse</returns>
publicboolUpdateCustomer(intcustId,stringcustName,stringaddress,stringlinkman)
{
Customercustomer=newCustomer();
CustomerInfocustomerInfo=newCustomerInfo(custId,custName,address,linkman);
returncustomer.UpdateCustomerByID(customerInfo);
}
///<summary>
///按ID删除一个客户信息
///</summary>
///<paramname="custId">客户号</param>
///<returns>bool范例,trueorfalse</returns>
publicboolDeleteCustomerByID(intcustId)
{
Customercustomer=newCustomer();
returncustomer.DeleteCustomerByID(custId);
}
///<summary>
///查询一切客户信息
///了局为IList
///</summary>
///<returns>一个客户汇合</returns>
publicIList<CustomerInfo>GetCustomersByAll()
{
Customercustomer=newCustomer();
returncustomer.GetCusomersByAll();
}
}
}
6、营业划定规矩层
usingSystem;
usingSystem.Collections.Generic;
usingSystem.Text;
usingcom.DataAccess;
usingcom.Model;
namespacecom.BusinessRule
{
///<summary>
///反省客户信息的正当性
///</summary>
publicclassCustomerRule
{
///<summary>
///反省客户的称号是不是已存在
///</summary>
///<remarks>
///e.g.:
///boolexist=CustomerRule.IsExistCustomerName(custName);
///</remarks>
///<paramname="custName">客户称号</param>
///<returns>客户存在与否</returns>
publicstaticboolIsExistCustomerName(stringcustName)
{
Customercust=newCustomer();
CustomerInfocustInfo=cust.GetCustomerByName(custName);
if(custInfo==null)
returnfalse;
else
returntrue;
}
}
}
7、营业表面层
usingSystem;
usingSystem.Collections.Generic;
usingSystem.Text;
usingSystem.Web.UI.WebControls;
usingcom.BusinessLogic;
usingcom.Model;
namespacecom.BusinessFacade
{
///<summary>
///为界面中Table处置数据
///</summary>
publicclassCustomerTable
{
publicstaticvoidSetTableData(Tabletable)
{
IList<CustomerInfo>list=newCustomerLogic().GetCustomersByAll();
AddRowHead(table);
foreach(CustomerInfocustinlist)
{
AddRow(table,cust);
}
}
privatestaticvoidAddRowHead(Tabletable)
{
TableCellcell=newTableCell();
cell.Text="Head";
TableRowrow=newTableRow();
row.Cells.Add(cell);
table.Rows.Add(row);
}
privatestaticvoidAddRow(Tabletable,CustomerInfocust)
{
TableRowrow=newTableRow();
TableCellcell1=newTableCell();
cell1.Text=cust.CustId.ToString();
TableCellcell2=newTableCell();
cell2.Text=cust.CustName;
TableCellcell3=newTableCell();
cell3.Text=cust.Address;
TableCellcell4=newTableCell();
cell4.Text=cust.Linkman;
row.Cells.Add(cell1);
row.Cells.Add(cell2);
row.Cells.Add(cell3);
row.Cells.Add(cell4);
table.Rows.Add(row);
}
}
}
8、界面层
<%@PageLanguage="C#"AutoEventWireup="true"CodeFile="Default.aspx.cs"Inherits="_Default"%>
<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<htmlxmlns="http://www.w3.org/1999/xhtml">
<headrunat="server">
<title>无题目页</title>
</head>
<body>
<formid="form1"runat="server">
<div>
</div>
<asp:ObjectDataSourceID="ObjectDataSource1"runat="server"
InsertMethod="InsertCustomer"SelectMethod="GetCustomersByAll"TypeName="com.BusinessLogic.CustomerLogic"DeleteMethod="DeleteCustomerByID"UpdateMethod="UpdateCustomer">
<DeleteParameters>
<asp:ControlParameterControlID="FormView1"PropertyName="SelectedValue"Name="custId"Type="Int32"/>
</DeleteParameters>
<UpdateParameters>
<asp:ParameterName="custId"Type="Int32"/>
<asp:ParameterName="custName"Type="String"/>
<asp:ParameterName="address"Type="String"/>
<asp:ParameterName="linkman"Type="String"/>
</UpdateParameters>
<InsertParameters>
<asp:ParameterName="custName"Type="String"/>
<asp:ParameterName="address"Type="String"/>
<asp:ParameterName="linkman"Type="String"/>
</InsertParameters>
</asp:ObjectDataSource>
<asp:FormViewID="FormView1"runat="server"DataSourceID="ObjectDataSource1"AllowPaging="True"DataKeyNames="custId">
<EditItemTemplate>
CustName:
<asp:TextBoxID="CustNameTextBox"runat="server"Text=<%#Bind("CustName")%>></asp:TextBox><br/>
Address:
<asp:TextBoxID="AddressTextBox"runat="server"Text=<%#Bind("Address")%>></asp:TextBox><br/>
Linkman:
<asp:TextBoxID="LinkmanTextBox"runat="server"Text=<%#Bind("Linkman")%>></asp:TextBox><br/>
CustId:
<asp:TextBoxID="CustIdTextBox"runat="server"BorderStyle="None"Enabled="False"
Text=<%#Bind("CustId")%>></asp:TextBox><br/>
<asp:LinkButtonID="UpdateButton"runat="server"CausesValidation="True"CommandName="Update"
Text="更新"></asp:LinkButton>
<asp:LinkButtonID="UpdateCancelButton"runat="server"CausesValidation="False"CommandName="Cancel"
Text="作废"></asp:LinkButton>
</EditItemTemplate>
<InsertItemTemplate>
CustName:
<asp:TextBoxID="CustNameTextBox"runat="server"Text=<%#Bind("CustName")%>></asp:TextBox><br/>
Address:
<asp:TextBoxID="AddressTextBox"runat="server"Text=<%#Bind("Address")%>></asp:TextBox><br/>
Linkman:
<asp:TextBoxID="LinkmanTextBox"runat="server"Text=<%#Bind("Linkman")%>></asp:TextBox><br/>
CustId:
<asp:TextBoxID="CustIdTextBox"runat="server"Text=0Enabled="False"></asp:TextBox><br/>
<asp:LinkButtonID="InsertButton"runat="server"CausesValidation="True"CommandName="Insert"
Text="拔出"></asp:LinkButton>
<asp:LinkButtonID="InsertCancelButton"runat="server"CausesValidation="False"CommandName="Cancel"
<P>Text="作废"></asp:LinkButton>
</InsertItemTemplate>
<ItemTemplate>
CustName:
<asp:LabelID="CustNameLabel"runat="server"Text=<%#Bind("CustName")%>></asp:Label><br/>
Address:
<asp:LabelID="AddressLabel"runat="server"Text=<%#Bind("Address")%>></asp:Label><br/>
Linkman:
<asp:LabelID="LinkmanLabel"runat="server"Text=<%#Bind("Linkman")%>></asp:Label><br/>
CustId:
<asp:LabelID="CustIdLabel"runat="server"Enabled="False"Text=<%#Bind("CustId")%>></asp:Label><br/>
<asp:LinkButtonID="EditButton"runat="server"CausesValidation="False"CommandName="Edit"
Text="编纂"></asp:LinkButton>
<asp:LinkButtonID="DeleteButton"runat="server"CausesValidation="False"CommandName="Delete"
Text="删除"></asp:LinkButton>
<asp:LinkButtonID="NewButton"runat="server"CausesValidation="False"CommandName="New"
Text="新建"兄弟们,想来你们都看过了昨天的比赛了。我现在的痛苦状跟当时应该差不多。希望本版.net老师不吝赐教,为小弟这一批迷途的羊羔指一条阳光之道!您也知道:学习技术如果只有一个人摸索,那是一件多么痛苦的事情!还有,如果万辛能得名师或长者指点,那又是多么一件幸福和快乐的事情!

若相依 发表于 2015-1-19 05:12:56

通过这次激烈的讨论,我从大家身上学到了太多,开阔了眼界,不管是支持我的还是骂我的,都感谢你们。

分手快乐 发表于 2015-1-24 06:02:53

我的意思是.net好用,从功能上来说比JAVA强还是很明显的。

乐观 发表于 2015-1-31 21:24:17

PHP的源代码完全公开,在OpenSource意识抬头的今天,它更是这方面的中流砥柱。不断地有新的函数库加入,以及不停地更新,使得PHP无论在UNIX或是Win32的平台上都可以有更多新的功能。它提供丰富的函数,使得在程式设计方面有着更好的资源。目前PHP的最新版本为4.1.1,它可以在Win32以及UNIX/Linux等几乎所有的平台上良好工作。PHP在4.0版后使用了全新的Zend引擎,其在最佳化之后的效率,比较传统CGI或者ASP等技术有了更好的表现。

谁可相欹 发表于 2015-2-6 22:59:47

JSP/Servlet虽然在国内目前的应用并不广泛,但是其前途不可限量。

简单生活 发表于 2015-2-19 01:08:43

由于CGI程序每响应一个客户就会打开一个新的进程,所以,当有多个用户同时进行CGI请求的时候,服务器就会打开多个进程,这样就加重了服务器的负担,使服务器的执行效率变得越来越低下。

冷月葬花魂 发表于 2015-3-6 12:02:15

弱类型造成潜在的出错可能:尽管弱数据类型的编程语言使用起来回方便一些,但相对于它所造成的出错几率是远远得不偿失的。

莫相离 发表于 2015-3-13 00:34:59

ASP.net1.1和2.0在程序上的语法也有很大不同,现在2.0属于新出来的,不知道半年后会不会有3.0(说笑一下)。Windows2003系统自动支持ASP和ASP.net环境,不用安装任何程序。Asp.net属于编译语言。ASP的最大不同(ASP属于解释语言)。

飘灵儿 发表于 2015-3-20 07:13:50

弱类型造成潜在的出错可能:尽管弱数据类型的编程语言使用起来回方便一些,但相对于它所造成的出错几率是远远得不偿失的。
页: [1]
查看完整版本: ASP.NET网页编程之ASP.NET2.0进修5--N层代码示例