加入收藏 - 网站地图 - 网站搜索 -
阅读新闻

Dreamwaver MX与ASP.NET(六)

[日期:02-02] [字体: ]
在弹出的对话框中,需将输入框和相对应更新的数据源关联起来,并设置数据类型。其中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.Form("tele"), "") % >' Type="WChar" / >

< Parameter Name="@ADDRESS" Value='< %# IIf((Request.Form("address") < > Nothing), Request.Form("address"), "") % >' Type="WChar" / >

< Parameter Name="@CODE" Value='< %# IIf((Request.Form("hiddenField") < > Nothing), Request.Form("hiddenField"), "") % >' Type="WChar" / >

< /Parameters >

< /MM:Update >

Dreamweaver MX是通过mm:update来表识更新的代码的。其格式和MM:Insert类似。


上一页 [1] [2]    
 
评论 】 【 推荐 】 【 打印
上一篇:DreamwaverMX与ASP.NET(五)
下一篇:DreamweaverMX实现网站批量更新