I am working on a windows form in vs2013.I am trying to display records based on a variable on to DataGridView when my form loads. I have tried a whole variety of code based on some google research.
Sep 17, 2016 - After i filter the DataGridView to a specific value on button click using the code below: private void btnFilterClick(object sender, EventArgs e).
I am connect form data to an access database.
Here is the code:
PS: What is the best way to store daily data? I will be inputting data on a daily basis. Should I create a table for monday, tuesday, etc?
I am having such a hard time with this. Any help is truly appreciated.
Thanksmelmatvar
melmatvarmelmatvar
![C Datagridview Filter C Datagridview Filter](http://csharp.net-informations.com/datagridview/img/dgv.png)
1 Answer
Get rid of your loop. Set the
DefaultView.RowFilter
of the DataTable
and then assign the DataTable
to the DataSource
of the grid. That's it: filter and bind. To filter, you actually have to assign a String
to the RowFilter
, e.g.That said, if you only want one day's data to display then you should only retrieve one day's data from the database. If you want to be able to change the filter without requerying then get all the data.
No, you should absolutely not create multiple tables. Each table represents a single entity. The entity is not different because it relates to a different day. One table with a column for the day/date/whatever is the correct option.
jmcilhinneyjmcilhinney27.1k33 gold badges2020 silver badges3333 bronze badges
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.