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

Asp.net中EditItemTemplate绑定数据方法

2011-08-21 21:35 423 查看
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)

{

#region 绑定ItemTemplate的方法

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

{

DropDownList ddl = (DropDownList)e.Row.FindControl("DropDownList1");

List<string> source = new List<string>();

source.Add("房屋");

source.Add("建筑");

ddl.DataSource = source;

ddl.DataBind();

CheckBox cb = (CheckBox)e.Row.FindControl("CheckBox1");

cb.Checked = true;

}

#endregion

#region 绑定EditItemTemplate的方法

if ((e.Row.RowState & DataControlRowState.Edit) != 0 && e.Row.RowType == DataControlRowType.DataRow)

{

DropDownList ddl = (DropDownList)e.Row.FindControl("DropDownList1");

List<string> source = new List<string>();

source.Add("房屋");

source.Add("建筑");

ddl.DataSource = source;

ddl.DataBind();

CheckBox cb = (CheckBox)e.Row.FindControl("CheckBox1");

cb.Checked = true;

}

#endregion

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