asp.net学习之扩展GridView
2014-05-04 17:46
281 查看
原文:asp.net学习之扩展GridView 本节讨论如何从现有的控件,进而扩展成强大的,更定制的GridView控件
1.扩展BoundField
默认的BoundField不能显示多文本,文字一多,就会扩大整个Table的Height值,解决这个问题的方法可以通过TemplateField加入Div控件来解决,但是,也可以从BoundField类上进行扩展,加入一点特有的功能,让他能够显示多文本
例1: 创建长文本字段
===App_code\myControls.cs===
1.扩展BoundField
默认的BoundField不能显示多文本,文字一多,就会扩大整个Table的Height值,解决这个问题的方法可以通过TemplateField加入Div控件来解决,但是,也可以从BoundField类上进行扩展,加入一点特有的功能,让他能够显示多文本例1: 创建长文本字段
===App_code\myControls.cs===
public class DeleteButtonField : ButtonField { private string _confirmMessage = "确认要删除吗?"; public string ConfirmMessage { get { return _confirmMessage; } set { _confirmMessage = value; } } // 默认情况下,作为删除按钮,按钮上显示删除字样 public DeleteButtonField() { this.CommandName = "Delete"; this.Text = "删除"; } public override void InitializeCell(DataControlFieldCell cell, DataControlCellType cellType, DataControlRowState rowState, int rowIndex) { base.InitializeCell(cell, cellType, rowState, rowIndex); if(cellType==DataControlCellType.DataCell) //如果是数据Cell { WebControl button = (WebControl)cell.Controls[0]; button.Attributes["onclick"] = String.Format("return confirm('{0}');", _confirmMessage); } } }
3.待续…
相关文章推荐
- asp.net学习之扩展GridView
- asp.net学习之扩展GridView
- asp.net学习之扩展GridView
- Asp.net学习笔记----使用GridView+ObjectDataSource进行自定义分页排序
- ASP.NET学习笔记2--自己写代码绑定Gridview
- ASP.NET学习笔记[11] - Gridview里的下拉框筛选效果
- ASP.NET学习笔记---- 数据查询与展示GridView
- 初学Asp.net关于GridView的一些学习记录
- asp.net学习之GridView事件、GridViewRow对象
- VS2005-ASP.NET GridView学习
- ASP.NET 3.5核心编程学习笔记(25):GridView控件
- asp.net学习之 数据绑定控件--表格绑定控件+asp.net学习GridView
- ASP.NET学习之GridView
- asp.net 学习笔记 从sql中取数据并且绑定到 gridView
- asp.net学习笔记 在GridView中添加链接
- asp.net学习之GridView七种字段
- 扩展ASP.NET 2.0内置GridView控件之一第一页
- Asp.Net Ajax 学习笔记18 Authentication Service的实现方式与扩展
- ASP.net中的AJAX学习记录六 无刷新的数据编辑(GridView和DetailsView结合实例)