VB.Net ComboBox (as Dropdown) not translating text to DisplayMember with Databinding -


i inherited large project @ work undocumented , written in vb (originally started pre .net, ended around .net 2). i'm in process of updating / refreshing lot of code, have run annoying issue haven't found solution yet. system utilizes ui, web service, , sql db.

problem: have databound combobox (originally set dropdownlist - i'm changing dropdown, started mess - going isn't option) tied dataset comes web service. when user types in item want manually, data text field doesn't seem associate displaymember, forces ws/sql query fail (it sent blank value when it's expecting valuemember). if user types in partial selection , chooses value want displaymember list using arrow keys or tab, query goes off without problem.

my question: how text field translate displaymember tie valuemember allow query execute correctly? sorry making sound complicated or convoluted; i'm sure answer easy , i'm glazing on it.

the relevant bit of code is:

with cmbdid     if dtslu.tables.contains(reqtable) = true         .datasource = dtslu.tables(reqtable)         .displaymember = "zip"         .valuemember = "gridid"      end if end cmbdid.databindings.clear() cmbdid.databindings.add("selectedvalue", dtsdata, strdt & ".gridid") 

i've tried changing "selectedvalue" "text", works - directly translates gridid , skips zip ends incorrect web service response since zip , gridid field values not synced (zip (displaymember) may 5123 while gridid (valuemember) may 6047). i've tried changing "selectedvalue" "selectedindex", , got me no where.

any appreciated.

edit add clarification process, below pseudo code / description happens. post whole module, feel muddy whole question more.

private sub     formalpha created 1 combobox in form of dropdown     dropdown populated dataset     databinding blank dataset added control keep track of users input end sub 

lblsubmit_click event triggered on formalpha user after have populated dropdown data. lblsubmit_click calls private sub submit

private sub submit     bindingcontext(dropdown dataset, tablename).endcurrentedit() called     dataset.haschanges() processed     if changes present, changes processed 

here lies problem

if user has manually typed in dropdown field, not hit arrow key or tab, dataset registers change, returns null value in fields - knows entered, data apparently didn't pass through dataset combobox (listitems or selectedindex didn't change / fire i'm guessing). if user selects item arrow keys, dataset has proper input (i'm assuming data validated control @ point).

    if processed data good, value entered database     if processed data bad (empty), error returned end sub 

if above can't solved i've provided, still knows better way handle type of situation, i'm ears. rewriting module isn't ideal, fixing problem necessity.

alright, while fix may not ideal, fix none less.

the bare bones problem text value of dropdown wasn't causing data affect selectedindex / selectedvalue of control unless interacted using arrow keys or mouse click. so, while dropdown read "1234", in reality control saw "".

the fix have in place calling combobox.text = combobox.text whenever user hits submit button.


Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -