c# - Setting the value of a combobox with datasource in ListView -
i have issue combobox not set binding value within list view.
as can see screenshot below, other values populating binding correctly. fact combobox opposed textbox/label?
the admin combo has 2 options, true or false. datatable listview (code below) bound contains values "true" , "false" various records.
<listview name="grdusers" horizontalalignment="left" itemssource="{binding}" margin="6,27,0,0" verticalalignment="top" height="225" width="289" scrollviewer.horizontalscrollbarvisibility="disabled"> <listview.view> <gridview > <gridviewcolumn displaymemberbinding="{binding path=pk}" header="pk" width="30"> </gridviewcolumn> <gridviewcolumn header="name" width="115"> <gridviewcolumn.celltemplate> <datatemplate> <textbox text="{binding path=name}" width="115"/> </datatemplate> </gridviewcolumn.celltemplate> </gridviewcolumn> <gridviewcolumn header="group" width="50"> <gridviewcolumn.celltemplate> <datatemplate> <textbox text="{binding path=membergroup}" width="45"/> </datatemplate> </gridviewcolumn.celltemplate> </gridviewcolumn> <gridviewcolumn header="admin" width="70"> <gridviewcolumn.celltemplate> <datatemplate> <combobox text="{binding path=isadmin}" width="55"> <comboboxitem>true</comboboxitem> <comboboxitem>false</comboboxitem> </combobox> </datatemplate> </gridviewcolumn.celltemplate> </gridviewcolumn> </gridview> </listview.view> </listview>
it last item within here issue, have tried changing binding selecteditem , sorts.
so, how bind datatable value combo , why not work combo , textboxes?
thanks
it's because combobox
has 2 items of comboboxitem
type , not string
, means selecteditem
of comboboxitem
type. try this:
<combobox selecteditem="{binding path=isadmin}" width="55"> <combobox.items> <sys:string>true</sys:string> <sys:string>false</sys:string> </combobox.items> </combobox>
for work you'll nee define sys:
namespace so:
xmlns:sys="clr-namespace:system;assembly=mscorlib"
Comments
Post a Comment