0
我綁定一個下拉列表,我有名字在第一列和姓氏作爲DDL第二column`無法填充下拉列表裏面的GridView
protected void GridView1_RowDataBound1(object sender, GridViewRowEventArgs e)
{
DataTable myTable = new DataTable();
DataColumn productIDColumn = new DataColumn("FirstName");
DataColumn productNameColumn = new DataColumn("LastName");
myTable.Columns.Add(productNameColumn);
DataSet ds = new DataSet();
ds = get();
if (e.Row.RowType == DataControlRowType.DataRow)
{
var fname= (e.Row.Cells[0].Text);
var expression = "FirstName "+fname;
DropDownList ddl = (DropDownList)e.Row.FindControl("DropDownList1");
DataRow[] rows = ds.Tables[0].Select(expression);
ddl.DataSource = myTable;
ddl.DataTextField = "LastName";
ddl.DataValueField = "LastName";
ddl.DataBind();
}
但DDL是空的無法填補DDL對此有何幫助?
第一列是否正確填充? –