Asp.net中EditItemTemplate绑定数据方法
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
}
posted on 2011-08-21 21:35 kisstome88 阅读(1136) 评论(0) 编辑 收藏 举报