性。
STEP 3数据更新
至于数据更新可以点击Application面板中的Server Behaviors中的”+”按钮,选择Update Record。

[图 6-9 选择Update Record]

[图6-10 设置关联]
在弹出的对话框中,需将输入框和相对应更新的数据源关联起来,并设置数据类型。其中CODE应为关键字即Primary Key。类似于Insert Record的页面,还要设置成功添加和添加失败跳转到的页面。
现在可以预览一下做好的页面。输入网址http://yoursite/location3.aspx,可以看到如图6-11的页面。

[图6-11 location3.aspx页面浏览]
Location_name的一项是可以点击的,并将跳到细节页面modify.aspx。

[图6-12 更新页面预览]
通过modify.aspx页面就可以修改现有数据,并可以通过表单提交事件来更新数据。
其更新的主要代码如下:
< MM:Update
runat="server"
CommandText='< %# "UPDATE LOCATIONS SET CITY=?, STATE_COUNTRY=?, FAX=?, TELEPHONE=?, ADDRESS=? WHERE CODE=?" % >'
ConnectionString='< %# System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_STRING_location") % >'
DatabaseType='< %# System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_DATABASETYPE_location") % >'
Expression='< %# Request.Form("MM_update") = "form1" % >'
CreateDataSet="false"
SuccessURL='< %# "location3.aspx" % >'
Debug="true"
>
< Parameters >
< Parameter Name="@CITY" Value='< %# IIf((Request.Form("city") < > Nothing), Request.Form("city"), "") % >' Type="WChar" / >
< Parameter Name="@STATE_COUNTRY" Value='< %# IIf((Request.Form("state") < > Nothing), Request.Form("state"), "") % >' Type="WChar" / >
< Parameter Name="@FAX" Value='< %# IIf((Request.Form("fax") < > Nothing), Request.Form("fax"), "") % >' Type="WChar" / >
< Parameter Name="@TELEPHONE" Value='< %# IIf((Request.Form("tele") < > Nothing), Request上一页 [1] [2] [3] 下一页