How do populate a ContextMenuStrip control using data from a SQL Server 2008 database
Posted on 2011-10-31
I have a VS2010 C# Windows application, and I want to add a ContextMenuStrip control to the form. I want to populate the ContextMenuStrip control with data from tables within my SQL Server 2008 database.For example, my ContextMenuStrip will have three menuitems: Projects, Deliverables, and Times. Under each of these items, I want to pull data from the database, and add the data to each menuitem. For Projects, the data will be pulled from "SELECT * FROM dbo.Projects", for Deliverables, the data will be pulled from "SELECT * FROM dbo.Tasks", and for Times, the data will be pulled from "SELECT * FROM dbo.WeekEndingDates". How would I go about doing? Another question I have is: once these menuitems are populated, is there a way to change them upon user selection? For example, if a user selects "Project 1" under the Projects menuitem, can the Deliverables menuitem be repopulated with all the data from the database that is associated with "Project 1"? Example: User selects "Project 1" from Projects menuitem, and then the Deliverables menuitem is populated with "SELECT * FROM dbo.Tasks WHERE Project = 'Project 1'".