I am working on a Windows Form Application where I have to edit a given record. This record also contains a dropdown list. What I want to do is to allow the user to edit the dropdown list item as well along with the rest of the record.
I have queried the required dropdown list item from the database that the user has to edit and assign that to a string variable like as follow:
DataTable dtMName = Products.SelectByManufacturerId(manufacturerId);
if (dtMName.Rows.Count > 0)
{
foreach (DataRow item in dtMName.Rows)
{
string manufacturerName = item[0].ToString();
}
}
Now, within the foreach loop (as the returned data row just have a single manufacturer name which the user will edit later), I want to select the dropdown list item that matches the string manufacturerName
.
As far, I have tried the following code but no luck.
childEditProduct.cmbManufacturer.SelectedIndex = childEditProduct.cmbManufacturer.FindString(manufacturerName);
Is there any problem with this approach for selecting the matching dropdown list item? or is there any effective way that can help in my case? Any help will highly be appreciated!