我正在绑定一个 DropDownList,我在第一列中有 FirstName,在第二列中有 LastName 作为 DDL
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 categoryID = (e.Row.Cells[0].Text);
var expression = "FirstName "+categoryID;
DropDownList ddl = (DropDownList)e.Row.FindControl("DropDownList1");
DataRow[] rows = ds.Tables[0].Select(expression);
foreach (DataRow row in rows)
{
DataRow newRow = myTable.NewRow();
newRow["UserId"] = row["UserId"];
newRow["LastName"] = row["LastName"];
myTable.Rows.Add(newRow);
}
ddl.DataSource = myTable;
ddl.DataTextField = "LastName";
ddl.DataValueField = "UserId";
ddl.DataBind();
}
}
我收到一个错误,例如Filter expression 'FirstName ' does not evaluate to a Boolean term
DataRow[] rows = ds.Tables[0].Select(expression);
谁能帮我这个??