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
}
{
#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
}
相关文章推荐
- ASP.NET数据绑定方法
- .net中的数据绑定,ObjectDataSource,Repeater,ItemTemplate,viewstate初步学习
- ASP.NET MVC 中将数据从View传递到控制器中的三种方法(表单数据绑定)
- 在ASP.NET 2.0中数据绑定的实现方法
- ASP.NET-GridView数据绑定的几种方法
- ASP.NET1.1数据绑定与ASP.NET2.0数据绑定的方法对比
- 在ASP.NET 2.0中数据绑定的实现方法
- asp.net数据绑定DataBind使用方法
- asp.net 数据绑定 使用eval 时候报 字符文本中的字符太多 问题的解决方法
- ASP.NET数据绑定方法集合
- ASP.NET中DropDownList下拉框列表控件绑定数据的4种方法
- Asp.Net--DropDownList与DataTable数据绑定的方法(C#)[学习笔记]
- ASP.NET数据绑定方法
- ASP.NET Eval进行数据绑定的方法
- asp.net的eval,bind,container.dateitem,数据绑定的研究
- ASP.NET 数据绑定控件和 Eval方法
- ASP.NET MVC 中将数据从View传递到控制器中的三种方法(表单数据绑定)
- ASP.Net应用深入系列(一):GridView行绑定时取得某个数据列的几种方法比较
- ASP.NET数据绑定方法集合
- asp.net 数据绑定 使用eval 时候报 字符文本中的字符太多 问题的解决方法