ASPX高性能分页Word文件下载.docx
- 文档编号:7740571
- 上传时间:2023-05-09
- 格式:DOCX
- 页数:25
- 大小:1.40MB
ASPX高性能分页Word文件下载.docx
《ASPX高性能分页Word文件下载.docx》由会员分享,可在线阅读,更多相关《ASPX高性能分页Word文件下载.docx(25页珍藏版)》请在冰点文库上搜索。
最终如下:
单击下一步完成。
自此我们的强类型数据集创建完毕了:
查看NotesData.Designer.cs可以看到VS以及自动帮我们生成强类型的数据表,一些相关事件以及TableAdaptor,并且给相应的方法标注了DataObjectMethodAttribute,我们可以直接在ObjectDataSource中使用。
三,在Default,aspx中添加ObjectDataSource,GridView,FormView控件
在页面中添加ObjectDataSource控件命名为ObjectDataSourceNotes,并配置数据源(配置之前请记得生成下项目):
定义数据方法,一般情况下,VS会自动设置TableAdaptor中的对应方法:
点击完成,即可查看到生成的控件标记如下:
<
asp:
ObjectDataSourceID="
ObjectDataSourceNotes"
runat="
server"
DeleteMethod="
Delete"
InsertMethod="
Insert"
OldValuesParameterFormatString="
original_{0}"
SelectMethod="
GetNotes"
TypeName="
DataAccessingSample.DAL.NotesDataTableAdapters.NotesTableAdapter"
UpdateMethod="
Update"
>
<
DeleteParameters>
ParameterName="
Original_NoteID"
Type="
Int32"
/>
Original_NoteTitle"
String"
Original_AddDateTime"
DateTime"
Original_NoteUser"
/DeleteParameters>
InsertParameters>
NoteTitle"
NoteContent"
AddDateTime"
NoteUser"
/InsertParameters>
UpdateParameters>
/UpdateParameters>
/asp:
ObjectDataSource>
从工具箱中拖拽GridView控件,设置其样式和数据源为刚添加的ObjectDataSource:
此控件的标记代码如下:
GridViewID="
GridViewNotes"
AllowPaging="
True"
AutoGenerateColumns="
False"
CellPadding="
4"
DataKeyNames="
NoteID"
DataSourceID="
EnableModelValidation="
ForeColor="
#333333"
PageSize="
5"
AlternatingRowStyleBackColor="
White"
Columns>
BoundFieldDataField="
HeaderText="
InsertVisible="
ReadOnly="
SortExpression="
CommandFieldShowDeleteButton="
ShowEditButton="
ShowSelectButton="
/Columns>
EmptyDataTemplate>
还没有留言。
/EmptyDataTemplate>
FooterStyleBackColor="
#990000"
Font-Bold="
HeaderStyleBackColor="
PagerStyleBackColor="
#FFCC66"
HorizontalAlign="
Center"
RowStyleBackColor="
#FFFBD6"
SelectedRowStyleBackColor="
Navy"
GridView>
生成项目打开页面,可以看到如下效果,目前尚无记录:
为了方便添加记录,我们在页面中拖拽一个按钮,以及一个FormView控件(数据源亦为ObjectDataSourceNotes),单击此按钮则显示FormView,FormView默认为添加模式,添加完毕后隐藏FormView。
这两个控件标记如下:
ButtonID="
ButtonAddNote"
onclick="
ButtonAddNote_Click"
Text="
AddNote"
br/>
FormViewID="
FormViewNotes"
DefaultMode="
GridLines="
Both"
oniteminserted="
FormViewNotes_ItemInserted"
Visible="
EditItemTemplate>
NoteID:
LabelID="
NoteIDLabel1"
Text='
%#Eval("
)%>
'
NoteTitle:
TextBoxID="
NoteTitleTextBox"
%#Bind("
NoteContent:
NoteContentTextBox"
AddDateTime:
AddDateTimeTextBox"
NoteUser:
NoteUserTextBox"
LinkButtonID="
UpdateButton"
CausesValidation="
CommandName="
更新"
&
nbsp;
UpdateCancelButton"
Cancel"
取消"
/EditItemTemplate>
HeaderTemplate>
Add/Modify/ViewNote
/HeaderTemplate>
InsertItemTemplate>
InsertButton"
插入"
InsertCancelButton"
InsertCancelButton_Click"
/InsertItemTemplate>
ItemTemplate>
NoteIDLabel"
NoteTitleLabel"
NoteContentLabel"
AddDateTimeLabel"
NoteUserLabel"
EditButton"
Edit"
编辑"
DeleteButton"
删除"
NewButton"
New"
新建"
/ItemTemplate>
FormView>
Code-Behind代码如下:
usingSystem;
usingSystem.Collections.Generic;
usingSystem.Web;
usingSystem.Web.UI;
usingSystem.Web.UI.WebControls;
namespaceDataAccessingSample
{
publicpartialclass_Default:
System.Web.UI.Page
{
protectedvoidPage_Load(objectsender,EventArgse)
}
protectedvoidButtonAddNote_Click(objectsender,EventArgse)
this.FormViewNotes.Visible=true;
protectedvoidInsertCancelButton_Click(objectsender,EventArgse)
this.FormVi
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- ASPX 性能 分页
![提示](https://static.bingdoc.com/images/bang_tan.gif)