Hi, I'm somewhat new to programming and have gotten stuck with the below problem using Winforms & Telerik UI w/ MVP, when trying to populate a pulldownlist (radpulldownlist):
I have a datagridview that displays data columns and values taken from mulitple SQL db tables copied to a new type that I created which contains all of the variables that I want to use in the datagridview. That new type is my data source. The datagridview is populated upon form load through an event I created. It works fine.
Below the datagridview are textboxes for user view and input/editing. When I click on the datagridview, the textboxes populate successfully with the datagridview data and I am able to clear, edit, enter data as desired.
Now, I'd like to change many of those textboxes into pulldownlist controls, so that users have to choose from available values for certain input fields, and I'd like to do this by loading each pulldownlist with data from a specific column from the datagridview datasource.
Right now, in my presenter, I have something similar to the following which is triggered on form load:
The above calls a method to get each record from db and put into a list that is then fed to datagridview object as datasource.
It references the following to bind the datagridview object with datasource:
Since that works fine and datagrid shows all column data correctly. I'm now trying to figure out how to do something similar which will call the same method to get each record from db and put into a list. THEN, from that list, I would like to only get data from a specific column from that list, and bind that to the pulldownlist as datasource.
I am lost as to how to do this, because I got the above code example online and got it working for my purposes but don't quite fully understand how it works fully, nor the options available to me to manipulate the list to get what I need out of it for the dropdownlist population.
For example, let's say there is a UserName column in the datasource which is a list of all records in the db. If I want ONLY that UserName column data to be fed to the dropdownlist to be used to populate the list of user selections available, could someone help shed some light on what I need to do to achieve this? I can use some variation of the above code to do so, but instead of feed it to datagridview object, feed it to pulldownlist object as datasource?
My plan is to then do the same for the rest of the pulldownlist controls I intend to use to replace some of the textboxes, using the same datasource for all of the pulldownlists controls, since it has the column data I need for each control.
Thanks in advance for your prompt reply. If more information is needed, I will gladly provide it promptly.
I have a datagridview that displays data columns and values taken from mulitple SQL db tables copied to a new type that I created which contains all of the variables that I want to use in the datagridview. That new type is my data source. The datagridview is populated upon form load through an event I created. It works fine.
Below the datagridview are textboxes for user view and input/editing. When I click on the datagridview, the textboxes populate successfully with the datagridview data and I am able to clear, edit, enter data as desired.
Now, I'd like to change many of those textboxes into pulldownlist controls, so that users have to choose from available values for certain input fields, and I'd like to do this by loading each pulldownlist with data from a specific column from the datagridview datasource.
Right now, in my presenter, I have something similar to the following which is triggered on form load:
private void LoadDGV(object sender, EventArgs e) { _view.DGV_All = _model.Get_ListAll().Select(x => new GridRow(x)).ToList(); }
The above calls a method to get each record from db and put into a list that is then fed to datagridview object as datasource.
It references the following to bind the datagridview object with datasource:
public IEnumerable<GridRow> DGV_All { set { dropDownList_UserName.DataSource = value; } }
Since that works fine and datagrid shows all column data correctly. I'm now trying to figure out how to do something similar which will call the same method to get each record from db and put into a list. THEN, from that list, I would like to only get data from a specific column from that list, and bind that to the pulldownlist as datasource.
I am lost as to how to do this, because I got the above code example online and got it working for my purposes but don't quite fully understand how it works fully, nor the options available to me to manipulate the list to get what I need out of it for the dropdownlist population.
For example, let's say there is a UserName column in the datasource which is a list of all records in the db. If I want ONLY that UserName column data to be fed to the dropdownlist to be used to populate the list of user selections available, could someone help shed some light on what I need to do to achieve this? I can use some variation of the above code to do so, but instead of feed it to datagridview object, feed it to pulldownlist object as datasource?
My plan is to then do the same for the rest of the pulldownlist controls I intend to use to replace some of the textboxes, using the same datasource for all of the pulldownlists controls, since it has the column data I need for each control.
Thanks in advance for your prompt reply. If more information is needed, I will gladly provide it promptly.
Last edited by a moderator: