I am binding a DropDownList, I have FirstName in the 1st column and LastName as a DDL in the second column
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();
}
}
I am getting an error like Filter expression 'FirstName ' does not evaluate to a Boolean term at DataRow[] rows = ds.Tables[0].Select(expression);
Can anyone help me with this??
Your expression doesn’t make any sense. I would expect something along the lines of:
or
Check out the docs for the Select method: http://msdn.microsoft.com/en-us/library/det4aw50.aspx