Click here to Skip to main content
15,868,016 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hai all,

In my Xaml page contains 1 combobox control (loading Districts from districtTable) ,textbox control to insert Taluk and Add button controls ,
For Add_Click event am inserting the District Id and Taluk names into database and displaying in a datagrid.Its working fine

Am facing problem during editing a datagrid, am getting District Id and district name on editing datagrid but not able to show in combobox (both DisplayMemberPath and SelectedValue)

Can any one help me in this please

Regards,
Sharath
Posted

I hope you are using twoway binding everywhere ?

HTML
<combobox height="40" horizontalalignment="Stretch" verticalalignment="Center">
  Name="vormComboBox" Grid.Column="1" Margin="2"
  ItemsSource="{Binding ElementName=materiaalComboBox,Path=SelectedItem.Vormen}" 
  SelectedValuePath="Model.VormId" 
  ItemTemplate="{StaticResource FotoMateriaalVormTemplate}"   
  SelectedValue="{Binding Model.FotoVormId,Mode=TwoWay}"   
  SelectionChanged="vormComboBox_SelectionChanged">
  <combobox.itemspanel>
    <itemspaneltemplate>
      <virtualizingstackpanel />
    </itemspaneltemplate>
  </combobox.itemspanel>
</combobox>
 
Share this answer
 
Comments
sharathrr 3-Aug-12 3:07am    
Hello,

In my Xaml page contains 1 combobox control (loading MainPurpose from MainPurposeTable) ,textbox control to insert Amount and Add button controls ,
For Add_Click event am inserting the MainPurpose Id and Amount into database and displaying in a datagrid.Its working fine

Am facing problem during editing a datagrid, am getting MainPurposeId and MainPurposeDesc on editing datagrid but not able to show in combobox (both DisplayMemberPath and SelectedValue)

<combobox height="23"
="" selectedvaluepath="MLnMnPurposeTId" displaymemberpath="MLnMnPurposeDesc" horizontalalignment="Left" margin="198,25,0,0" name="cmbMnPurpose" selectedvalue="{Binding MSubPurposeTId,Mode=TwoWay}" verticalalignment="Top" width="189">

<sdk:datagrid autogeneratecolumns="False" height="147" horizontalalignment="Left" margin="24,286,0,0" name="GrdGCA" loadingrow="GrdGCA_LoadingRow" verticalalignment="Top" width="682">

private void GrdGCA_LoadingRow(object sender, DataGridRowEventArgs e)
{
e.Row.MouseLeftButtonUp += new System.Windows.Input.MouseButtonEventHandler(Row_MouseLeftButtonUp);
}

void Row_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
MnSubPurpose Puropse = GrdGCA.SelectedItem as MnSubPurpose;
LoadGCAMainPurpose();
cmbMnPurpose.SelectedValue = Puropse.MLnMnPurposeTId;
cmbMnPurpose.DisplayMemberPath = Puropse.MLnMnPurposeDesc;
cmbSubPurpose.SelectedValue = Puropse.MLnSubPurposeTId;
}



Can any one help me in this please

Regards,
Sharath
Philip Stuyck 3-Aug-12 3:36am    
The whole point of WPF is to use binding and to put the GUI as much as possible in the xaml. I suggest you read a bit more about xaml and binding. The easiest way to learn is to jump in the MVVM design pattern.
May be you can add a EditItemTemplate inside your DataGrid.

Inside the specified column add a ComboBox field and bind its DataBinding property to your seleted value. Set the ItemSource, SelectedValuePath, SelectedDisplayMemberPath as you require it.

Hope it helps.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900