GridView控件初步使用概括11.23
来源:互联网 发布:旧版本windows.old 编辑:程序博客网 时间:2024/06/05 10:32
这类控件的使用鼠标操作很多!所以不是很好解释,接下来我就概括的介绍下GridView控件的初步知识!
GridView包含以下列:
• 绑定列 (常用列)
• 图片列
• 超级链接列
• 复选框列
• 按钮列
• 命令列
• 模版列 (重点,灵活性大大提高)
如何访问GridView中的数据?(重点)
LinkButton lbtn = e.Row.Cells[6].Controls[0] as LinkButton; //除模板列之外的特殊列,使用单元格的Controls集合去访问
HyperLink link = e.Row.Cells[1].Controls[0] as HyperLink;
string sid = e.Row.Cells[0].Text; //普通的绑定列,通过Text属性去访问
Image img = e.Row.Cells[5].FindControl("Image1") as Image; //适合在模板列查找
GridView控件可以通过行和列来控制外观样式
整体外观控制:布局、分页、外观
行外观控制:项、交替项、编辑项、选中项、页眉、页脚、分页、空数据项
如何为删除按钮增加提示? (GridView1_RowDataBound事件是在更新数据行时调用的事件)
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType != DataControlRowType.DataRow)
return;
//if ((e.Row.RowState & DataControlRowState.Edit) == DataControlRowState.Edit) //效果同下
// return;
if(e.Row.Cells[6].Controls.Count == 0) //点击编辑时,删除列会隐藏。为了解决索引超出问题的方法
return;
LinkButton lbtn = e.Row.Cells[6].Controls[0] as LinkButton;
string sname = e.Row.Cells[1].Text;
if (lbtn != null)
{
lbtn.Attributes.Add("onclick", "return confirm('确认要删除" + sname + "吗?')");
}
}
{
if (e.Row.RowType != DataControlRowType.DataRow)
return;
//if ((e.Row.RowState & DataControlRowState.Edit) == DataControlRowState.Edit) //效果同下
// return;
if(e.Row.Cells[6].Controls.Count == 0) //点击编辑时,删除列会隐藏。为了解决索引超出问题的方法
return;
LinkButton lbtn = e.Row.Cells[6].Controls[0] as LinkButton;
string sname = e.Row.Cells[1].Text;
if (lbtn != null)
{
lbtn.Attributes.Add("onclick", "return confirm('确认要删除" + sname + "吗?')");
}
}
Eval单向绑定!从数据源调用数据到UI
Bind为双向绑定!可以实现从数据源到UI从UI到数据源的双向传值和绑定!
实现 确认,取消 对话框的代码 confirm("确定删除?")
- GridView控件初步使用概括11.23
- 初步的概括
- GridView常用属性概括
- FileUpload控件使用初步
- FloatingActionButton控件初步使用
- GridView控件使用经验
- GridView控件使用常见问题
- GridView控件使用经验
- gridview控件使用
- Gridview控件使用详解
- GridView控件的使用
- GridView控件使用经验
- GridView控件使用
- GridView控件的使用
- GridView控件使用经验
- GridView控件使用经验
- gridview控件使用心得
- GridView控件使用
- 整个文件夹的拷贝 void CopyFolder( LPCTSTR pszSrc, LPCTSTR pszDes )
- C#的switch语句
- java 2D 游戏教程
- C#的switch语句(2)
- Trixbox CE 安装手记
- GridView控件初步使用概括11.23
- AMBA总线介绍
- 关联关系的级联操作
- 简单XNA_Windows Phone 7 3D动画
- xp win2003 远程桌面同步解决办法,绝对有效
- hibernate 支持的集合类型
- 小试vCenter 5.0安装
- 删除一个目录下所有文件及文件夹 BOOL DeleteDirectory(LPCTSTR pszPath)
- Android4: ACTION_BOOT_COMPLETED开机启动程序需要声明权限