DataContext, Stored Procedure and bindings.

2 posts, 0 answers
  1. Grzesiek
    Grzesiek avatar
    100 posts
    Member since:
    Jun 2007

    Posted 16 Jan Link to this post

         Hello,

    In my database I have stored procedure which returns me the clients list. I'm binding it to AutoCompleteBox like below:

     

    var y = DC.ClientGetAll();
    ClientList.ItemsSource = new ObservableCollection<ClientGetAllResult>(y);

     

    In XAML:

                    <telerik:RadAutoCompleteBox x:Name="ClientList" ItemsSource="{Binding}"
                       TextSearchMode="Contains"
                                                DisplayMemberPath="Name" 
                                                AutoCompleteMode="SuggestAppend" 
                                                SelectionMode="Single" Margin="107,72,16,0" 
                                                VerticalAlignment="Top"
                                                SelectedItem="{Binding}"
                                                />

     

    And everything is OK.

    But now I want, to create edit form for my users and after open form, AutoCompleteBox should show selected item (by ID).

    I was tried everything, but without result.

    Can you help me?

  2. Dinko
    Admin
    Dinko avatar
    955 posts

    Posted 18 Jan Link to this post

    Hi Grzesiek,

    If I have understood your scenario correctly, you want the dropdown items to be displayed by Value property but when you select an item to be displayed by ID property. IF this is the case, I can't suggest you approach which you could try in Single selection mode. In multiple selection mode, you could try using BoxesItemTemplate and specify custom DataTemplate in which there is TextBlock bind to a different property.

    An approach which you could try (in Single mode) is to set the DisplayMemberPath property to ID and set the TextSearchPath to Value. This way the control will search for an item using Value property and shows ID property. You can additionally customize the DropDownItem by specifying DropDownItemTemplate property so it contains more information.

    Regards,
    Dinko
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top