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
}