我想獲得一個「模糊」搜索工作在DataTable綁定到DataTable。搜索數據表
我想使用DataTable.Select,但我沒有看到它的工作。這裏是我的代碼:
private void buttonSearch_Click(object sender, EventArgs e)
{
string SearchString;
if (this.textSearchString.Text == "")
{
return;
}
SearchString = this.textSearchString.Text;
DataRow[] rows = dt.Select("PartName Like '" + SearchString + "%'");
dt.Rows.Clear();
foreach (DataRow row in rows)
{
dt.Rows.Add(row.ItemArray);
}
this.datagridInventory.DataSource = null;
LoadInventoryList(); //loads up dt and formats columns
}
我不確定這是否正確,它似乎不工作。有人可以指出我的錯誤或更好地向我解釋這個概念嗎?
很棒!感謝它現在有道理。 – Ryan