I have VS2012, Winform app. In my Search form, I do a search via txtbox & cboboxes where my dropdown list display all names, which is correct binding. But once I click btnSearch, my datagridviewtextboxColumn displays the correct ID, not the name. I manually binded my controls to the dgv with a bindingsource. how do I display the name that is correct in my cbobox, to also display in my dgv column?
Searchdgv:
column: InvestigatorID
datapropertyName: InvestigatorID
columnType: datagridviewtextboxColumn
InvestigatorBLL property:
public int? ID {get; set; }
Code
public String DisplayName {get; set;}Code
public string DisplayValue {get { return DisplayName; } }Code
//PickListItemClassC#
public PicklistItem(IPickListItem item, bool enabled)
{
ID = item.ID;
Description = item.DisplayValue;
Enabled = enabled; }
//bind data
bindingSource1.DataSource = data;
dgvSearch.AutoGenerateColumns = false;
dgvSearch.DataSource = data.ToSortableBindingList();
private void btnSearch_Click(object sender, EventArgs e)
{
BindData();
if (bindingSource1.Count <= 0)
{
MessageBox.Show("No results returned. Clear your search and enter a new case.");
return;
}
dgvSearch.DataSource = bindingSource1;
}Code
How do I get my dgv to display name? InvestigatorName=John Doe; InvestigatorID=2. I need the name, but I get ID.Code
Thank you in advance.1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
sammi taylor19 pointsPosted Apr 17, 2015, 6:26 PM EDT