views:

1114

answers:

3

I have a datagridview(dgv) with a DataGridViewComboBoxColumn(colLocation)

colLocation.AutoComplete = False
colLocation.HeaderText = "Stored to"
colLocation.DataSource = DB.getLocation()
colLocation.DisplayMember = "description"
colLocation.ValueMember = "id"

I added the colLocation to dgv.

"descirption" contains Unicode characters. I can see the comboBox correctly and choose the item.

The problem is when the comboBox lost the focus, the value is changed to first item of the comboBox.

Any suggestion?

Updated:

I found out that the ComboBox doesn't change the data when the DisplayMember is in English characters.

It changes only when the DisplayMember is in Unicode chracter. Any idea for how could solve this? – tunwn 0 secs ago

A: 

Your .aspx page should have something like so:

<asp:DropDownList Width="90px" ID="ddlExpenseTypes" OnSelectedIndexChanged="ddlExpenseTypes_SelectedIndexChanged"  DataSource='<%# GetExpenseTypes() %>' SelectedValue='<%# Bind("ExpenseReasonID") %>' DataTextField="ExpenseReasonID" DataValueField="ExpenseReasonID" AutoPostBack="true"  runat="server" ></asp:DropDownList>

That is you need a functional call for index changed. A function call for filling the drop down ist (DataSource) and a function call to set the SelectedValue of the drop down list.

JonH
A: 

Not sure...but his might help.

http://msdn.microsoft.com/en-us/library/system.windows.forms.combobox.selectedtext.aspx

dc
A: 

Is this DataGridView databound? You haven't specified a value for DataPropertyName, so there's nothing for colLocation.ValueMember's ID selection to bind to.

CodeByMoonlight