【发布时间】:2013-03-08 14:58:02
【问题描述】:
我有一个带有 3 列(产品、数量、价格)的网格视图,带有页眉和页脚。我为产品页脚添加了一个下拉列表。现在我想将此下拉列表与数据集中的产品绑定,有人可以帮助我吗? 我在cs文件中使用了以下代码,但在查找控件附近出现错误
"对象引用未设置为对象的实例。
protected void gv_page2_RowDataBound(object sender, GridViewRowEventArgs e)
{
dal = new DAL();
ds = new DataSet();
ds=dal.DALBindFooterDDL();
if (e.Row.RowType == DataControlRowType.Footer)
{
DropDownList ddl = (DropDownList)gv_page2.FooterRow.FindControl("ftrDDL");
ddl.DataSource = ds.Tables[0];
ddl.DataBind();
}
}
【问题讨论】:
-
你应该使用 gridview RowDataBound 事件