QPhome# 青浦之家论坛

QQ登录

只需一步,快速开始

2122

积分

13

好友

374

主题
1
发表于 2007-4-15 22:57:43 | 查看: 3313| 回复: 2
1.简单数据绑定定

[size=13px]http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif[color=#008000]<!--[/color][color=#008000]ASP.NET 1.x data binding expression [/color][color=#008000]-->[/color][color=#000000]
http://ghd258.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gifhttp://ghd258.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif[/color][color=#000000]<%[/color]http://www.cnblogs.com/Images/dot.gif[color=#000000]# DataBinder.Eval(Container.DataItem, [/color][color=#000000]"[/color][color=#000000]Price[/color][color=#000000]"[/color][color=#000000]) [/color][color=#000000]%>[/color][color=#000000]
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif[/color][color=#008000]<!--[/color][color=#008000]Equivalent ASP.NET 2.0 data binding expression [/color][color=#008000]-->[/color][color=#000000]
http://ghd258.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gifhttp://ghd258.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif[/color][color=#000000]<%[/color]http://www.cnblogs.com/Images/dot.gif[color=#000000]# [/color][color=#0000ff]Eval[/color][color=#000000]([/color][color=#000000]"[/color][color=#000000]Price[/color][color=#000000]"[/color][color=#000000]) [/color][color=#000000]%>[/color][color=#000000]
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif[/color][color=#008000]<!--[/color][color=#008000]XML data binding [/color][color=#008000]-->[/color][color=#000000]
http://ghd258.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gifhttp://ghd258.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif[/color][color=#000000]<%[/color]http://www.cnblogs.com/Images/dot.gif[color=#000000]# XPath([/color][color=#000000]"[/color][color=#000000]Price[/color][color=#000000]"[/color][color=#000000]) [/color][color=#000000]%>[/color][/size]
2.数据源控件
[size=13px]http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif[color=#000000]控件名                                     控件描述
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gifSqlDataSource                       一切支持SQL语句的数据源控件
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gifAccessDataSource               Access数据源控件
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gifXmlDataSource                     XML数据源控件
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gifObjectDataSource                自行编写组件的数据源控件
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gifSiteMapDataSource             页面导航控件的数据源控件[/color][/size]
2.1 SqlDataSource关键属性
[size=13px]http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif[color=#000000]名称                                               描述
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gifConnectionString                        连接数据库的连接字符串
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gifSelectCommand                           用于执行查询的命令
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gifInsertCommand                           用于执行插入的命令
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gifUpdateCommand                        用于执行更新的命令
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gifDeleteCommand                          用于执行删除的命令
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gifDataSourceMode                        指定数据源类型是DataSet 或DataReader( 默认值[/color][color=#000000]=[/color][color=#000000] DataSet)
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gifProviderName                              指定供应商(默认值[/color][color=#000000]=[/color][color=#000000] SQL Server .NET provider)[/color][/size]
2.2 SqlDataSource 支持通过以下属性进行数据缓存
[size=13px]http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif[color=#000000]属性名                                         描述
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gifEnableCaching                           指定是否打开缓存(默认值[/color][color=#000000]=[/color][color=#000000] [/color][color=#0000ff]false[/color][color=#000000])
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gifCacheDuration                           指定结果被缓存多少妙
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gifCacheExpirationPolicy              指定缓存间隔是sliding 还是absolute
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gifCacheKeyDependency             使缓存依赖于一个特定键值
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gifSqlCacheDependency               使缓存依赖于一个特定数据库实体[/color][/size]
2.3 参数化命令  XxxParameter 类型指定参数来源
[size=13px]http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif[color=#000000]名称                                      描述
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gifSelectParameters                为查询命令指定参数
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gifInsertParameters                为插入命令指定参数
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gifUpdateParameters              为更新命令指定参数
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gifDeleteParameters               为删除命令指定参数
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gifFilterParameters                 为过滤器命令指定参数[/color][/size]
2.4 XxxParameter 类型
[size=13px]http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif[color=#000000]名称                                               描述
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gifControlParameter                         指定一个源自于控件的参数
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gifCookieParameter                          指定一个源自于cookie的参数
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gifFormParameter                             指定一个源自于表单的参数
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gifProfileParameter                           指定一个源自于profile的参数
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gifQueryStringParameter                 制定于一个来源于查询字符串的参数
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gifParameter                                      为数据源绑定一个参数
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gifSessionParameter                        指定一个源自于session的参数[/color][/size]
2.5 使用ControlParameter例子 [size=13px]http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif[color=#0000ff]<[/color][color=#800000]asp:SqlDataSourceID[/color][color=#0000ff]="Countries"[/color][color=#ff0000] RunAt[/color][color=#0000ff]="server"[/color][color=#ff0000]
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gifConnectionString[/color][color=#0000ff]="server=localhost;database=northwind;"[/color][color=#ff0000]
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gifSelectCommand[/color][color=#0000ff]="select distinct country from customers order by country"[/color][color=#ff0000] [/color][color=#0000ff]/>[/color][color=#000000]
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif[/color][color=#0000ff]<[/color][color=#800000]asp:SqlDataSourceID[/color][color=#0000ff]="Customers"[/color][color=#ff0000] RunAt[/color][color=#0000ff]="server"[/color][color=#ff0000]
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gifConnectionString[/color][color=#0000ff]="server=localhost;database=northwind;"[/color][color=#ff0000]
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gifSelectCommand[/color][color=#0000ff]="select * from customers where country =@Country"[/color][color=#0000ff]>[/color][color=#000000]
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif[/color][color=#0000ff]<[/color][color=#800000]SelectParameters[/color][color=#0000ff]>[/color][color=#000000]
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif[/color][color=#0000ff]<[/color][color=#800000]asp:ControlParameterName[/color][color=#0000ff]="Country"[/color][color=#ff0000] ControlID[/color][color=#0000ff]="MyDropDownList"[/color][color=#ff0000]
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gifPropertyName[/color][color=#0000ff]="SelectedValue"[/color][color=#ff0000] [/color][color=#0000ff]/>[/color][color=#000000]
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif[/color][color=#0000ff]</[/color][color=#800000]SelectParameters[/color][color=#0000ff]>[/color][color=#000000]
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif[/color][color=#0000ff]</[/color][color=#800000]asp:SqlDataSource[/color][color=#0000ff]>[/color][color=#000000]
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif[/color][color=#0000ff]<[/color][color=#800000]aspropDownListID[/color][color=#0000ff]=" MyDropDownList"[/color][color=#ff0000] DataSourceID[/color][color=#0000ff]="Countries"[/color][color=#ff0000]
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gifDataTextField[/color][color=#0000ff]="country"[/color][color=#ff0000] AutoPostBack[/color][color=#0000ff]="true"[/color][color=#ff0000] RunAt[/color][color=#0000ff]="server"[/color][color=#ff0000] [/color][color=#0000ff]/>[/color][color=#000000]
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif[/color][color=#0000ff]<[/color][color=#800000]aspataGridDataSourceID[/color][color=#0000ff]="Customers"[/color][color=#ff0000] RunAt[/color][color=#0000ff]="server"[/color][color=#ff0000] [/color][color=#0000ff]/>[/color][/size]
2.7 调研存储过程例子
[size=13px]http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif[color=#0000ff]<[/color][color=#800000]asp:SqlDataSourceID[/color][color=#0000ff]="Countries"[/color][color=#ff0000] RunAt[/color][color=#0000ff]="server"[/color][color=#ff0000]
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gifConnectionString[/color][color=#0000ff]="server=localhost;database=northwind;"[/color][color=#ff0000]
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gifSelectCommand[/color][color=#0000ff]="proc_GetCountries"[/color][color=#ff0000] [/color][color=#0000ff]/>[/color][color=#000000]
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif[/color][color=#0000ff]<[/color][color=#800000]asp:SqlDataSourceID[/color][color=#0000ff]="Customers"[/color][color=#ff0000] RunAt[/color][color=#0000ff]="server"[/color][color=#ff0000]
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gifConnectionString[/color][color=#0000ff]="server=localhost;database=northwind;"[/color][color=#ff0000]
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gifSelectCommand[/color][color=#0000ff]="proc_GetCustomers"[/color][color=#0000ff]>[/color][color=#000000]
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif[/color][color=#0000ff]<[/color][color=#800000]SelectParameters[/color][color=#0000ff]>[/color][color=#000000]
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif[/color][color=#0000ff]<[/color][color=#800000]asp:ControlParameterName[/color][color=#0000ff]="Country"[/color][color=#ff0000] ControlID[/color][color=#0000ff]="MyDropDownList"[/color][color=#ff0000]
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gifPropertyName[/color][color=#0000ff]="SelectedValue"[/color][color=#ff0000] [/color][color=#0000ff]/>[/color][color=#000000]
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif[/color][color=#0000ff]</[/color][color=#800000]SelectParameters[/color][color=#0000ff]>[/color][color=#000000]
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif[/color][color=#0000ff]</[/color][color=#800000]asp:SqlDataSource[/color][color=#0000ff]>[/color][color=#000000]
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif[/color][color=#0000ff]<[/color][color=#800000]aspropDownListID[/color][color=#0000ff]="MyDropDownList"[/color][color=#ff0000] DataSourceID[/color][color=#0000ff]="Countries"[/color][color=#ff0000]
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gifDataTextField[/color][color=#0000ff]="country"[/color][color=#ff0000] AutoPostBack[/color][color=#0000ff]="true"[/color][color=#ff0000] RunAt[/color][color=#0000ff]="server"[/color][color=#ff0000] [/color][color=#0000ff]/>[/color][color=#000000]
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif[/color][color=#0000ff]<[/color][color=#800000]asp:DataGridDataSourceID[/color][color=#0000ff]="Customers"[/color][color=#ff0000] RunAt[/color][color=#0000ff]="server"[/color][color=#ff0000] [/color][color=#0000ff]/>[/color][color=#000000]
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gifCREATE PROCEDURE proc_GetCustomers
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif@Country nvarchar(32) AS
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gifSELECT * FROM Customers
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gifWHERE Country = @Country
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gifGO
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gifCREATE PROCEDURE proc_GetCustomers
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gifCREATE PROCEDURE proc_GetCountriesAS
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gifSELECT DISTINCT Country
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gifFROM Customers
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gifORDER BY Country
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gifGO[/color][/size]
3.XmlDataSource 使用XML 作为数据源
[font=Times New Roman][size=3][color=#000000]支持缓存与XSL 转换,只支持查询绑定,不支持更新
[/color][/size][/font][size=13px]http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif[color=#0000ff]<[/color][color=#800000]asp:XmlDataSourceID[/color][color=#0000ff]="Rates"[/color][color=#ff0000] DataFile[/color][color=#0000ff]="Rates.xml"[/color][color=#ff0000] RunAt[/color][color=#0000ff]="server"[/color][color=#ff0000] [/color][color=#0000ff]/>[/color][color=#000000]
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif[/color][color=#0000ff]<[/color][color=#800000]asp:TreeViewID[/color][color=#0000ff]="MyTreeView"[/color][color=#ff0000] DataSourceID[/color][color=#0000ff]="Rates"[/color][color=#ff0000] RunAt[/color][color=#0000ff]="server"[/color][color=#ff0000] [/color][color=#0000ff]/>[/color][/size]
3.1 XmlDataSource的关键属性
[size=13px]http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif[color=#000000]名称                                                    描述
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gifDataFile XML                                    数据文件的路径
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gifTransformFile                                    含有XSL 风格定义的数据文件路径
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gifEnableCaching                                  指定是否开启cache (默认值[color=#000000]=[/color][color=#000000] [/color][color=#0000ff]false[/color][color=#000000])[/color]
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gifXPath XPath                                      表达式用来确认数据
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gifCacheDuration                                  以秒为单位的时间间隔
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gifCacheExpirationPolicy                     指定时间间隔是sliding 还是absolute
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gifCacheKeyDependency                    创建缓存依存于某个键
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif[/color][/size]
4. ObjectDataSource
从数据组件绑定数据,提供中间件的数据绑定,使数据访问和UI脱离,两种数据绑定方式
SelectMethod, InsertMethod, UpdateMethod,and DeleteMethod
可选择是否使用缓存,可选择是否使用参数
4.1 ODS 关键属性
[size=13px]http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif[color=#000000]ODS 关键属性
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif名称                                                         描述
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gifInsertParameters                                    指定插入方法参数
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gifUpdateParameters                                 指定更新方法参数
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gifDeleteParameters                                   指定删除方法参数
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gifSelectParameters                                    指定查询方法参数
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gifCacheDuration                                       缓存间隔时间以秒为单位
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gifSqlCacheDependency                          基于某个数据实体的缓存
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif创建和清除
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gifObjectDataSource.SelectMethod 可以使用静态方法也可以使用一个类的新实例
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif如果使用实例方法:ODS 在每次调用的时候创建一个新实例类必须具有公共的建构函数
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif使用ObjectCreated 和ObjectDisposing 元素可以初始化和撤销函数[/color][/size]
[font=Times New Roman][size=3][color=#000000]5.增强的DataGrid 控件
[font=Times New Roman][size=3][color=#000000]支持复杂的数据单元格类型,包括CheckBoxFields在<Columns> 元素中声明高可定制的用户界面
gridView 列类型:
[size=13px]http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif[color=#000000]名称                                             描述
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gifBoundField                                 显示数据库中取出的文本
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gifButtonField                                显示按钮
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gifCheckBoxField                           使用check boxes显示一个boolean型变量
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gifHyperLinkField                          显示一个超链接
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gifTemplateField                            显示一个自定义的HTML模板
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gifCommandField                          显示一个查询或者编辑按钮
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gifImageField                                 显示一个图片[/color][/size]
[/color][/size][/font][/color][/size][/font][font=Times New Roman][size=3][color=#000000]6. 冲突判定
[size=13px]http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif[color=#000000][color=red][color=#000000][color=#ff0000][color=#ff0000][color=red][color=#000000]先入胜利[/color][/color]
[/color][/color][/color][/color]http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif如果数据在取出之后被改变,则修改失败
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gifUpdateCommand结构构成指定ConflictDetection[/color][color=#000000]=[/color][color=#000000]“CompareAllValues”来实现
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif后入胜利
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif无论数据是否被修改,该修改都会成功
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gifUpdateCommand结构构成指定ConflictDetection[/color][color=#000000]=[/color][color=#000000]“OverwriteChanges”来实现[/color][/size]
6.1 先入胜利法则更新
[code]<asp:SqlDataSourceID="Employees" RunAt="server"
ConnectionString="server=localhost;database=northwind;"
SelectCommand="select employeeid, lastname, firstnamefrom employees"
UpdateCommand="update employees set lastname=@lastname, firstname=
@firstnamewhere employeeid=@original_employeeid and lastname=
@original_lastnameand firstname=@original_firstname"
ConflictDetection="CompareAllValues">
<UpdateParameters>
<asparameterName="EmployeeID" Type="Int32" />
<asparameterName="lastname" Type="String" />
<asparameterName="firstname" Type="String" />
</UpdateParameters>
</asp:SqlDataSource>
<asp:GridViewDataSourceID="Employees" Width="100%" RunAt="server"
DataKeyNames="EmployeeID" AutoGenerateEditButton="true" />[/code]
7.[font=Times New Roman][size=3][color=#000000]错误检测[/color][/size][/font]
[font=Times New Roman][size=3][color=#000000]数据更新后控件调用的事件[font=Times New Roman][size=3][color=#000000]GridView.RowUpdated,DetailsView.ItemUpdated,SqlDataSource.Updated, etc.
处理“status”的事件,无论数据库是否异常允许数据库异常被处理或者再次抛弃,显示多少数据库行被修改
[font=Times New Roman][size=3][color=#000000]处理更新错误[/color][/size][/font]
[size=13px]http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif[color=#0000ff]<[/color][color=#800000]asp:SqlDataSourceID[/color][color=#0000ff]="Employees"[/color][color=#ff0000] RunAt[/color][color=#0000ff]="server"[/color][color=#ff0000]
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gifUpdateCommand[/color][color=#0000ff]=""[/color][color=#ff0000] OnUpdated[/color][color=#0000ff]="OnUpdateComplete"[/color][color=#0000ff]>[/color][color=#000000]
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif[/color][color=#0000ff]</[/color][color=#800000]asp:SqlDataSource[/color][color=#0000ff]>[/color][color=#000000]
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gifvoid OnUpdateComplete (Object source, SqlDataSourceStatusEventsArgse)
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif{
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gifif (e.Exception!= null) {
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif// Exception thrown. Set e.ExceptionHandledto true to prevent
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif// the SqlDataSourcefrom throwing an exception, or leave it set
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif// to false to allow SqlDataSourceto rethrowthe exception
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif}
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gifelse if (e.AffectedRows== 0) {
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif// No exception was thrown, but no records were updated,either.
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif// Might want to let the user know that the update failed
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif}
http://ghd258.cnblogs.com/Images/OutliningIndicators/None.gif}[/color][/size]
[/color][/size][/font][/color][/size][/font][/color][/size][/font]

[[i] 本帖最后由 uynetwork 于 2007-4-15 23:01 编辑 [/i]]
分享到: QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
转发到微博

收藏回复 只看该作者 道具 举报

2
发表于 2007-4-24 10:12:55
7.错误检测
数据更新后控件调用的事件GridView.RowUpdated,DetailsView.ItemUpdated,SqlDataSource.Updated, etc.
处理“status”的事件,无论数据库是否异常允许数据库异常被处理或者再次抛弃,显示多少数据库行被修改
处理更新错误
<asp:SqlDataSourceID="Employees" RunAt="server"
UpdateCommand="" OnUpdated="OnUpdateComplete">

</asp:SqlDataSource>

void OnUpdateComplete (Object source, SqlDataSourceStatusEventsArgse)
{
if (e.Exception!= null) {
// Exception thrown. Set e.ExceptionHandledto true to prevent
// the SqlDataSourcefrom throwing an exception, or leave it set
// to false to allow SqlDataSourceto rethrowthe exception
}
else if (e.AffectedRows== 0) {
// No exception was thrown, but no records were updated,either.
// Might want to let the user know that the update failed
}
}

回复 只看该作者 道具 举报

3
发表于 2007-4-24 10:13:42
7.错误检测
数据更新后控件调用的事件GridView.RowUpdated,DetailsView.ItemUpdated,SqlDataSource.Updated, etc.
处理“status”的事件,无论数据库是否异常允许数据库异常被处理或者再次抛弃,显示多少数据库行被修改
处理更新错误
<asp:SqlDataSourceID="Employees" RunAt="server"
UpdateCommand="" OnUpdated="OnUpdateComplete">

</asp:SqlDataSource>

void OnUpdateComplete (Object source, SqlDataSourceStatusEventsArgse)
{
if (e.Exception!= null) {
// Exception thrown. Set e.ExceptionHandledto true to prevent
// the SqlDataSourcefrom throwing an exception, or leave it set
// to false to allow SqlDataSourceto rethrowthe exception
}
else if (e.AffectedRows== 0) {
// No exception was thrown, but no records were updated,either.
// Might want to let the user know that the update failed
}
}

回复 只看该作者 道具 举报

您需要登录后才可以回帖 登录 | 注册

回顶部