Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
180
UltraDropDown case sensitive lookup on underling data source
posted

In my ultragrid I have a column hooked to an UltraDropDown to show a meaningful description of the underling value.

DataSource of the UltraDropDown:

Value -  Description
M_Key1 - "Description of Master Key 1"
M_Key2 - "Description of Master Key 2"
M_Key3 - "Description of Master Key 3"

 


DataSource of the Ultragrid (I report only the data in the UltraDropDown's column)

UddColumn's Data
M_Key1 ----> On screen UltraDropDown correctly show the text "Description of Master Key 1"
m_key2 -----> On screen UltraDropDown show the text "m_key2" instead of "Description of Master Key 2"

 

Why does the UltraDropDown show the correct description text only if the ValueMember have the exact same case?
How can I make the UltraDropDown case-insensitive, so that it will show the correct description even when the case of the ValueMember text are different?
I don't have control over the data underling the ultragrid because this data come from the DB, and I don't know the characters "case" that have been used for data entry.

Thanks,
Max

  • 1610
    Offline posted

    Hey, I have the same issue!

    I was looking for a property or so that would make the dropdownlist ValueMember as case insensitive instead of case sensitive. does it exist?

    Thanks

  • 71886
    Offline posted

    Hello Max,

    A possible approach to achieve this would be to use an event like 'BeforeExitEditMode' of the grid and to check for string equality using, for example, the 'ToLower()' method. Something similar to the following code sample:

    private void ultraGrid1_BeforeExitEditMode(object sender, BeforeExitEditModeEventArgs e) {

     foreach (UltraGridRow row in ultraDropDown1.Rows) {

     if (ultraGrid1.ActiveCell.Text.ToLower() == row.Cells[0].Value.ToString().ToLower() && ultraGrid1.ActiveCell.Text != "") {

     ultraGrid1.ActiveCell.Value = row.Cells[1].Text;

    } } }

    Please feel free to let me know if I misunderstood you or if you have any other questions.