这是我的DataGrid中内嵌DropDownList的绑定的代码:
private void ddls(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{DataSet dsBranch=GetDs("select * from branch_name","TBranch");
DropDownList ddl=(DropDownList)e.Item.FindControl("ddl1"); ddl.DataSource=dsBranch.Tables["TBranch"];
ddl.DataTextField="branch_name";
ddl.DataValueField="branch_id";
ddl.DataBind();
}
为什么运行时总提示: “Webform.DropDownList”并不包含对“DataSource”的定义
“Webform.DropDownList”并不包含对“DataTextField”的定义
“Webform.DropDownList”并不包含对“DataValueField”的定义
这是什么原因啊。大家帮帮我。
private void ddls(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{DataSet dsBranch=GetDs("select * from branch_name","TBranch");
DropDownList ddl=(DropDownList)e.Item.FindControl("ddl1"); ddl.DataSource=dsBranch.Tables["TBranch"];
ddl.DataTextField="branch_name";
ddl.DataValueField="branch_id";
ddl.DataBind();
}
为什么运行时总提示: “Webform.DropDownList”并不包含对“DataSource”的定义
“Webform.DropDownList”并不包含对“DataTextField”的定义
“Webform.DropDownList”并不包含对“DataValueField”的定义
这是什么原因啊。大家帮帮我。
ddl.DataSource=dsBranch.Tables["TBranch"]; 行错误
没将对像设置到对像引用。
用e.item.cell[index].findcontrol取控件吧
后 dll为null