悬赏分:5 浏览:497 次
请看下面,下面是怎么会事?
在下面的中DropDownList1上绑定了数据。
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType ==DataControlRowType.DataRow)
{
DataSet Ds = new DataSet();
DropDownList ddl = (DropDownList)e.Row.FindControl("DropDownList1");
string Name = "GetBooks";//存储过程名字
int strWhere = 0;//表示查询条件为空
//访问类库的Sql静态方法
Ds = DB.GetList(Name, strWhere);
if (Ds.Tables[0].Rows.Count != 0)
{
///绑定数据
ddl.DataSource = Ds;
ddl.DataTextField = "AuthorName";
ddl.DataValueField = "AuthorName";
}
// Button btnDel = (Button)e.Row.FindControl("btndel");
// btnDel.Attributes.Add("onclick", "return confirm('真的要删除吗?')");
}
}
在下面的中DropDownList1上绑定不了数据。
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
////DataSet Ds = new DataSet();
////DropDownList ddl = (DropDownList)e.Row.FindControl("DropDownList1");
////string Name = "GetBooks";//存储过程名字
&