扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
作者:冷枫 来源:CSDN 2007年9月23日
关键字:
在本页阅读全文(共2页)
<asp:XmlDataSourceID="Rates" DataFile="Rates.xml" RunAt="server" />
<asp:TreeViewID="MyTreeView" DataSourceID="Rates" RunAt="server" />
名称 描述
DataFile XML 数据文件的路径
TransformFile 含有XSL 风格定义的数据文件路径
EnableCaching 指定是否开启cache (默认值= false)
XPath XPath 表达式用来确认数据
CacheDuration 以秒为单位的时间间隔
CacheExpirationPolicy 指定时间间隔是sliding 还是absolute
CacheKeyDependency 创建缓存依存于某个键
ODS 关键属性
名称 描述
InsertParameters 指定插入方法参数
UpdateParameters 指定更新方法参数
DeleteParameters 指定删除方法参数
SelectParameters 指定查询方法参数
CacheDuration 缓存间隔时间以秒为单位
SqlCacheDependency 基于某个数据实体的缓存
创建和清除
ObjectDataSource.SelectMethod 可以使用静态方法也可以使用一个类的新实例
如果使用实例方法:ODS 在每次调用的时候创建一个新实例类必须具有公共的建构函数
使用ObjectCreated 和ObjectDisposing 元素可以初始化和撤销函数
名称 描述
BoundField 显示数据库中取出的文本
ButtonField 显示按钮
CheckBoxField 使用check boxes显示一个boolean型变量
HyperLinkField 显示一个超链接
TemplateField 显示一个自定义的HTML模板
CommandField 显示一个查询或者编辑按钮
ImageField 显示一个图片
先入胜利
如果数据在取出之后被改变,则修改失败
UpdateCommand结构构成指定ConflictDetection=“CompareAllValues”来实现
后入胜利
无论数据是否被修改,该修改都会成功
UpdateCommand结构构成指定ConflictDetection=“OverwriteChanges”来实现
<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>
<asp:ParameterName="EmployeeID" Type="Int32" />
<asp:ParameterName="lastname" Type="String" />
<asp:ParameterName="firstname" Type="String" />
</UpdateParameters>
</asp:SqlDataSource>
<asp:GridViewDataSourceID="Employees" Width="100%" RunAt="server"
DataKeyNames="EmployeeID" AutoGenerateEditButton="true" />
<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
}
}Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=800944
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。