您的位置:首页 > 编程语言 > ASP

asp.net高级应用之GridView控件

2011-11-23 18:03 441 查看
当使用数据源控件作为Gridview的数据源时,需要使用GridView的

DataSourceID属性来指定

并且不需要调用DataBind方法

GridView控件自定义列知识点

如何为删除按钮增加提示及如何访问GridView中的数据



protected void GridView1_RowDataBound(object sender,GridViewRowEventArgs e)

{

if(e.Row.RowType.RowType!=DataControlRowType.DataRow)

return;

LinkButton lbtn=e.row.Cell[7].Controls[0] as LinkButton;
//除模板列之外的特殊列,使用单元格的Controls集合去访问

string sid=e.Row.Cells[0].Text;
//普通绑定列,通过单元格的Text去访问

Image img=e.Row.Cells[5].FindControl("Image1") as Image; //适合在模板列中查找

if(lbtn!=null)

lbtn.Attributes.Add("onclick","return confirm('确定要删除吗?')")

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: