TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Denis Morgan
NA
72
20.7k
Filter Datagrid View from data populated from entity in C#
Aug 4 2020 6:59 AM
I am newbie in C# and probably this might be a possible duplicate but am unable to do filter of records on datagrid view whose columns were designed from designer view on TextBox change event.
This is my code to populate the datagridview. Any help will be highly appreciated.
IList<ProductEntity> emp = HibernateDao.fetchDAta();
IList<ProductModel> products =
new
List<ProductModel>();
foreach
(ProductEntity e
in
emp)
{
dataGridView1.Rows.Add(
""
+ e.id, e.barcode, e.product_name, e.product_desc, e.quantity +
" "
+ e.units,
""
+e.buying_price,e.retail_selling_price,e.can_sell_whole_sale,e.whole_selling_price);
}
And this is the code that have tried to do filter which is not working at all
BindingSource bs=
new
BindingSource();
private
void
metroTextBox1_TextChanged(
object
sender, EventArgs e)
{
if
(metroTextBox1.Text ==
string
.Empty)
{
bs.RemoveFilter();
}
else
{
bs.Filter =
string
.Format(
"product_name LIKE '*{0}*'"
, metroTextBox1.Text);
}
}
Reply
Answers (
1
)
Windows Server Reboot search in splunk
I need help to make a c# script