I’m an amateur in C#.NET programming.
I need to populate a grid with data from a table I’ve created based on the “date (date type)” given by the user from a date picker put in a textbox. There is a submit button which populates the grid using the date.
I need to know how to connect to the database and the grid and how to populate it with the date given in the textbox. I do not know anything about grid views.
I couldn’t find a relevant site in google for my problem. I’ll be more than happy if someone could provide with a general code or a link regarding my problem.
Thanks in advance 🙂
This involves understanding a few different technologies. I don’t think you’ll find a single source for all of this. Since this is a general question, I’ll give you general guidance.
Oracle
To connect to Oracle, you’ll want to use Oracle’s DataAccess component (ODAC). Read a few of the API examples that comes with the ODAC to learn how to connect to the database and execute commands. It is very similar to ADO.NET.
When extracting information from the database as the result of a query, you’ll want to load the database data into a local .NET class object. This is what you will feed your data grid.
WPF/Winforms
How you bind your results to the DataGrid will depend on whether or not you are using WPF vs Winforms. If you are using WPF, you will want to research ItemsSource binding and the INotifyPropertyChanged interface. Essentially, you’ll store a list (typically an
ObservableCollection<T>) of your result entities and bind the DataGrid’s ItemSource property to the list. You’ll then define what columns you want to display in the grid and how those map to the properties of the database entity.I’m not as familiar with the Winforms grids, but I believe there is a way to bind to those as well.