datalist控件没有内置的分页功能,所以对于分页需自己写程序去实现;本示例还包括了DataList的所有基本操作,如添加,删除,修改,选择等;具体代码如下:
前台代码:Default.aspx
----------------------------------------
<%@ Page language="c#" Codebehind="Default.aspx.cs" AutoEventWireup="false" Inherits="Example.DataListTest" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>DataListTest</title>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
<style type="text/css">TD { FONT-SIZE: 12px; COLOR: #000000; FONT-FAMILY: "宋体" }
</style>
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<table cellSpacing="0" cellPadding="0" width="100%" border="0">
<tr>
<td><a href="DlNested.aspx">DataList嵌套实例</a></td>
</tr>
<tr>
<td>
<table cellSpacing="0" borderColorDark="white" cellPadding="0" width="100%" align="center"
border="1">
<tr>
<td><asp:datalist id="DataList1" runat="server" Width="90%" Height="280px" RepeatColumns="2" RepeatDirection="Horizontal"
RepeatLayout="Flow">
<headertemplate>
<table id="Table6" cellspacing="0" bordercolordark="white" cellpadding="0" width="100%"
border="1">
<tr>
<td width="80%"><font face="宋体">TypeName</font></td>
<td width="50"><font face="宋体">选择</font></td>
<td width="50"><font face="宋体">确定</font></td>
<td width="50"><font face="宋体">删除</font></td>
</tr>
</table>
</headertemplate>
<selecteditemtemplate>
<font face="宋体">
<table id="Table3" cellspacing="0" cellpadding="0" width="100%" border="1" bordercolordark="white">
<tr>
<td><font face="宋体">TypeID</font></td>
<td><font face="宋体" color="#ff3366"><font face="宋体">TypeName</font></font></td>
</tr>
<tr>
<td style="HEIGHT: 21px"><font face="宋体">
<asp:Label id=lblTypeID runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "I_TypeID") %>'>
</asp:Label></font></td>
<td style="HEIGHT: 21px"><font face="宋体" color="#ff3366">
<asp:Label id=lblTypeName runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "C_TypeName") %>'>
</asp:Label></font></td>
</tr>
<tr>
<td colspan="2">
<asp:Button id="btnBack" runat="server" CommandName="cancel" Text="返回"></asp:Button></td>
</tr>
</table>
</font>
</selecteditemtemplate>
<footertemplate>
<table id="Table8" cellspacing="0" bordercolordark="white" cellpadding="0" width="100%"
border="1">
<tr>
<td><font face="宋体">TypeID</font></td>
<td>
<asp:TextBox id="txtTypeIDInsert" runat="server"></asp:TextBox></td>
<td><font face="宋体">TypeName</font></td>
<td>
<asp:TextBox id="txtTypeNameInsert" runat="server"></asp:TextBox></td>
<td align="center">
<asp:Button id="btnInsert" runat="server" Text="新增" CommandName="Insert"></asp:Button></td>
</tr>
</table>
</footertemplate>
<itemtemplate>
<table cellspacing="0" cellpadding="0" width="100%" border="1" bordercolordark="white">
<tr>
<td width="80%"><font face="宋体" color="red">
<%# DataBinder.Eval(Container.DataItem,"C_TypeName")%>
</font>
</td>
<td width="50">
<asp:Button id="btnSelect" runat="server" CommandName="select" Text="选择"></asp:Button></td>
<td width="50">
<asp:Button id="btnModify" runat="server" CommandName="edit" Text="编辑" EnableViewState="true"></asp:Button></td>
<td width="50"><font face="宋体">
<asp:Button id=btnDelete runat="server" CommandName="delete" Text="删除" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "I_TypeID") %>'>
</asp:Button></font></td>
</tr>
</table>
</itemtemplate>
<edititemtemplate>
<table id="Table2" cellspacing="0" cellpadding="0" width="100%" border="1">
<tr>
<td style="WIDTH: 75px; HEIGHT: 23px"><font face="宋体"><font face="宋体">TypeName</font></font></td>
<td style="HEIGHT: 23px"><font face="宋体" color="#ff3366">
<asp:TextBox id=txtTypeName runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "C_TypeName") %>'>
</asp:TextBox></font></td>
</tr>
<tr>
<td style="WIDTH: 75px"><font face="宋体">
<asp:Button id=btnUpdate runat="server" CommandName="update" Text="更新" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "I_TypeID") %>'>
</asp:Button></font></td>
<td><font face="宋体" color="#ff3366">
<asp:Button id="btnCancle" runat="server" CommandName="cancel" Text="取消"></asp:Button></font></td>
</tr>
</table>
</edititemtemplate>
</asp:datalist></td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<TABLE cellSpacing="0" borderColorDark="white" cellPadding="0" width="100%" border="1">
<TR align="center">
<TD noWrap width="10%">共
<asp:label id="lblRecNum" runat="server"></asp:label>条记录</TD>
<TD noWrap width="30%">第
<asp:label id="lblCurPageNO" runat="server"></asp:label>页/共
<asp:label id="lblPageNum" runat="server"></asp:label>页</TD>
<TD noWrap width="5%"><asp:button id="btnFirst" runat="server" Text="首页"></asp:button></TD>
<TD noWrap width="5%"><asp:button id="btnPreview" runat="server" Text="上页"></asp:button></TD>
<TD noWrap width="5%"><asp:button id="btnNext" runat="server" Text="下页"></asp:button></TD>
<TD noWrap width="5%"><asp:button id="btnLast" runat="server" Text="末页"></asp:button></TD>
<TD noWrap width="20%">每页<asp:dropdownlist id="ddlPageRowNum" runat="server" AutoPostBack="True"></asp:dropdownlist>行</TD>
<TD noWrap width="20%">转到
<asp:dropdownlist id="ddlJumpToPageNum" runat="server" AutoPostBack="True"></asp:dropdownlist>页</TD>
</TR>
</TABLE>
</td>
</tr>
</table>
</form>
</body>
</HTML>
后台代码:Default.aspx.cs
----------------------------------------
/*----------------------------------------------------------------
// 版权所有: 亿思维软件工作室
// 网站地址: Http://www.easewe.com
// 联系方式: 87015203(QQ),easewe@126.com(Email)
// 整理日期: 2005.09.14
//----------------------------------------------------------------*/
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.OleDb;
namespace Example
{
/// <summary>
/// DataListTest 的摘要说明。
/// </summary>
public class DataListTest : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DataList DataList1;
protected System.Web.UI.WebControls.Label lblRecNum;
protected System.Web.UI.WebControls.Label lblCurPageNO;
prot
没有合适的资源?快使用搜索试试~ 我知道了~
DataGrid常用操作
共49个文件
txt:30个
rar:3个
cs:3个
需积分: 0 32 下载量 84 浏览量
2008-04-18
09:41:51
上传
评论
收藏 185KB RAR 举报
温馨提示
C#.net中datagrid控件的一些常用的操作。
资源详情
资源评论
资源推荐
收起资源包目录
DataGrid常用操作.rar (49个子文件)
net文档
ASP.NET常用代码.txt 24KB
ASP.net 验证码(C#) .txt 3KB
DataGrid和DropDownList的一些配合以及使用css定制DataGrid .txt 8KB
Reapter.rar 41KB
aspnet班考勤表.xls 23KB
DataList分页、增加、删除、修改实例.txt 26KB
在DataGrid中显示数据库中的图片.txt 5KB
使用单击和双击更新DataGrid中的数据的例子.txt 7KB
DataGrid实现自定义分页,鼠标移至变色,删除确认、可编辑,可删除.txt 8KB
身份证号码15位升18位(C#).txt 4KB
如何读取保存在数据库中的图片显示在DataGrid中.txt 1KB
DataGrid全攻略.txt 2KB
DataList.rar 41KB
DataGrid中加入CheckBox,并实现单选 .txt 5KB
在两个ASP.NET页面之间传递值 .txt 4KB
DataGrid实现自增列、单选、多选 .txt 6KB
datagrid数据导出到excel文件给客户端下载的几种方法 .txt 4KB
如何给DataGrid添加自动增长列 .txt 3KB
收集]常用正则表达式.txt 948B
DataGrid自定义分页以及几种常用的删除方法 .txt 17KB
新建 文本文档.txt 910B
用.net操作word .txt 4KB
DataGrid数据导入Excel.txt 979B
DataGrid入门经典 .txt 12KB
一个功能齐全的DataGrid分页例子(两种方法) .txt 11KB
为ASP.NET封装的SQL数据库访问类.txt 9KB
DateGrid中模板列添加属性.txt 3KB
WebAdManger0.rar 19KB
关于datagrid的几点简单应用.txt 13KB
DataList嵌套实例.txt 9KB
Asp.Net细节性问题精萃.txt 9KB
ADO.Net都有哪些从数据库获取数据的方式 .txt 4KB
选择DataGrid中的CheckBox控件后该行背景变色 .txt 2KB
汇总c#.net常用函数和方法集.txt 6KB
WebAdManger0
WebAdManger0
WebAdManger0.sln 939B
Global.asax.cs 1KB
Ad.xml 642B
Global.asax 79B
bin
WebAdManger0.pdb 22KB
WebAdManger0.dll 20KB
Web.config 4KB
Manager.aspx.cs 4KB
Manager.aspx 5KB
WebAdManger0.csproj 6KB
WebAdManger0.csproj.webinfo 122B
Manager.aspx.resx 5KB
Global.asax.resx 2KB
WebAdManger0.suo 8KB
AssemblyInfo.cs 2KB
共 49 条
- 1
ngdgycc
- 粉丝: 0
- 资源: 10
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0