Combobox in WPF unable to add hardcode values with database values












-1















XAML Code:



        <ComboBox  x:Name="CbLinge" HorizontalAlignment="right" Margin="0,150,0,0" VerticalAlignment="Top" Width="300" Height="25" RenderTransformOrigin="1.018,0.565 " 
ItemsSource="{Binding GetLinge}"
DisplayMemberPath="Linge"
SelectedValuePath="Linge"
SelectedValue="{Binding FinishedManual.Ligne}"/>


C# Code:



  public void _fillLinge()
{
List<FinishedManualPrintingLinge> linge = _finishedProductService.GetFinishedManualLinge().ToList();
foreach (var item in linge)
{
GetLinge.Add(item);
}

}


By This piece of code,I'm able to get the values from database and able to display in Dropdown.



Problem:
The dropdown list for "Ligne" is linked to data available in order table. But if any order for the line, then it is not visible in drop-down "Ligne". So, it should be hardcoded/ populated by (1,4,6,7,8,9,10).



Now, I am not sure how to display the hardcode values if order : x is selected.










share|improve this question























  • What do you mean by But if any order for the line, then it is not visible in drop-down "Ligne".?

    – Alain Elemia
    Nov 22 '18 at 5:10











  • try to filter as this one stackoverflow.com/a/16938351/713789

    – Anirudha Gupta
    Nov 22 '18 at 5:11











  • @Alain: example we have 1 more drop-down above which is displaying orders. Now if user select the order which doesn't have and existing value of linge. So in that case my drop- down will show (1,4,6,7,8,9,10) values.

    – Naman
    Nov 22 '18 at 6:53











  • So you want to have a FallBack value for your collection Binding. It is easy enough, also you clicked on combobox and rotated it a bit, you don't need SelectedValuePath when you use SelectedValue.

    – XAMlMAX
    Nov 22 '18 at 8:34











  • Have you had any luck with this?

    – XAMlMAX
    Nov 26 '18 at 10:17
















-1















XAML Code:



        <ComboBox  x:Name="CbLinge" HorizontalAlignment="right" Margin="0,150,0,0" VerticalAlignment="Top" Width="300" Height="25" RenderTransformOrigin="1.018,0.565 " 
ItemsSource="{Binding GetLinge}"
DisplayMemberPath="Linge"
SelectedValuePath="Linge"
SelectedValue="{Binding FinishedManual.Ligne}"/>


C# Code:



  public void _fillLinge()
{
List<FinishedManualPrintingLinge> linge = _finishedProductService.GetFinishedManualLinge().ToList();
foreach (var item in linge)
{
GetLinge.Add(item);
}

}


By This piece of code,I'm able to get the values from database and able to display in Dropdown.



Problem:
The dropdown list for "Ligne" is linked to data available in order table. But if any order for the line, then it is not visible in drop-down "Ligne". So, it should be hardcoded/ populated by (1,4,6,7,8,9,10).



Now, I am not sure how to display the hardcode values if order : x is selected.










share|improve this question























  • What do you mean by But if any order for the line, then it is not visible in drop-down "Ligne".?

    – Alain Elemia
    Nov 22 '18 at 5:10











  • try to filter as this one stackoverflow.com/a/16938351/713789

    – Anirudha Gupta
    Nov 22 '18 at 5:11











  • @Alain: example we have 1 more drop-down above which is displaying orders. Now if user select the order which doesn't have and existing value of linge. So in that case my drop- down will show (1,4,6,7,8,9,10) values.

    – Naman
    Nov 22 '18 at 6:53











  • So you want to have a FallBack value for your collection Binding. It is easy enough, also you clicked on combobox and rotated it a bit, you don't need SelectedValuePath when you use SelectedValue.

    – XAMlMAX
    Nov 22 '18 at 8:34











  • Have you had any luck with this?

    – XAMlMAX
    Nov 26 '18 at 10:17














-1












-1








-1








XAML Code:



        <ComboBox  x:Name="CbLinge" HorizontalAlignment="right" Margin="0,150,0,0" VerticalAlignment="Top" Width="300" Height="25" RenderTransformOrigin="1.018,0.565 " 
ItemsSource="{Binding GetLinge}"
DisplayMemberPath="Linge"
SelectedValuePath="Linge"
SelectedValue="{Binding FinishedManual.Ligne}"/>


C# Code:



  public void _fillLinge()
{
List<FinishedManualPrintingLinge> linge = _finishedProductService.GetFinishedManualLinge().ToList();
foreach (var item in linge)
{
GetLinge.Add(item);
}

}


By This piece of code,I'm able to get the values from database and able to display in Dropdown.



Problem:
The dropdown list for "Ligne" is linked to data available in order table. But if any order for the line, then it is not visible in drop-down "Ligne". So, it should be hardcoded/ populated by (1,4,6,7,8,9,10).



Now, I am not sure how to display the hardcode values if order : x is selected.










share|improve this question














XAML Code:



        <ComboBox  x:Name="CbLinge" HorizontalAlignment="right" Margin="0,150,0,0" VerticalAlignment="Top" Width="300" Height="25" RenderTransformOrigin="1.018,0.565 " 
ItemsSource="{Binding GetLinge}"
DisplayMemberPath="Linge"
SelectedValuePath="Linge"
SelectedValue="{Binding FinishedManual.Ligne}"/>


C# Code:



  public void _fillLinge()
{
List<FinishedManualPrintingLinge> linge = _finishedProductService.GetFinishedManualLinge().ToList();
foreach (var item in linge)
{
GetLinge.Add(item);
}

}


By This piece of code,I'm able to get the values from database and able to display in Dropdown.



Problem:
The dropdown list for "Ligne" is linked to data available in order table. But if any order for the line, then it is not visible in drop-down "Ligne". So, it should be hardcoded/ populated by (1,4,6,7,8,9,10).



Now, I am not sure how to display the hardcode values if order : x is selected.







c# wpf






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 22 '18 at 5:01









NamanNaman

67




67













  • What do you mean by But if any order for the line, then it is not visible in drop-down "Ligne".?

    – Alain Elemia
    Nov 22 '18 at 5:10











  • try to filter as this one stackoverflow.com/a/16938351/713789

    – Anirudha Gupta
    Nov 22 '18 at 5:11











  • @Alain: example we have 1 more drop-down above which is displaying orders. Now if user select the order which doesn't have and existing value of linge. So in that case my drop- down will show (1,4,6,7,8,9,10) values.

    – Naman
    Nov 22 '18 at 6:53











  • So you want to have a FallBack value for your collection Binding. It is easy enough, also you clicked on combobox and rotated it a bit, you don't need SelectedValuePath when you use SelectedValue.

    – XAMlMAX
    Nov 22 '18 at 8:34











  • Have you had any luck with this?

    – XAMlMAX
    Nov 26 '18 at 10:17



















  • What do you mean by But if any order for the line, then it is not visible in drop-down "Ligne".?

    – Alain Elemia
    Nov 22 '18 at 5:10











  • try to filter as this one stackoverflow.com/a/16938351/713789

    – Anirudha Gupta
    Nov 22 '18 at 5:11











  • @Alain: example we have 1 more drop-down above which is displaying orders. Now if user select the order which doesn't have and existing value of linge. So in that case my drop- down will show (1,4,6,7,8,9,10) values.

    – Naman
    Nov 22 '18 at 6:53











  • So you want to have a FallBack value for your collection Binding. It is easy enough, also you clicked on combobox and rotated it a bit, you don't need SelectedValuePath when you use SelectedValue.

    – XAMlMAX
    Nov 22 '18 at 8:34











  • Have you had any luck with this?

    – XAMlMAX
    Nov 26 '18 at 10:17

















What do you mean by But if any order for the line, then it is not visible in drop-down "Ligne".?

– Alain Elemia
Nov 22 '18 at 5:10





What do you mean by But if any order for the line, then it is not visible in drop-down "Ligne".?

– Alain Elemia
Nov 22 '18 at 5:10













try to filter as this one stackoverflow.com/a/16938351/713789

– Anirudha Gupta
Nov 22 '18 at 5:11





try to filter as this one stackoverflow.com/a/16938351/713789

– Anirudha Gupta
Nov 22 '18 at 5:11













@Alain: example we have 1 more drop-down above which is displaying orders. Now if user select the order which doesn't have and existing value of linge. So in that case my drop- down will show (1,4,6,7,8,9,10) values.

– Naman
Nov 22 '18 at 6:53





@Alain: example we have 1 more drop-down above which is displaying orders. Now if user select the order which doesn't have and existing value of linge. So in that case my drop- down will show (1,4,6,7,8,9,10) values.

– Naman
Nov 22 '18 at 6:53













So you want to have a FallBack value for your collection Binding. It is easy enough, also you clicked on combobox and rotated it a bit, you don't need SelectedValuePath when you use SelectedValue.

– XAMlMAX
Nov 22 '18 at 8:34





So you want to have a FallBack value for your collection Binding. It is easy enough, also you clicked on combobox and rotated it a bit, you don't need SelectedValuePath when you use SelectedValue.

– XAMlMAX
Nov 22 '18 at 8:34













Have you had any luck with this?

– XAMlMAX
Nov 26 '18 at 10:17





Have you had any luck with this?

– XAMlMAX
Nov 26 '18 at 10:17












1 Answer
1






active

oldest

votes


















0














OPTION 1

Display a hardcoded set of values:

Here is how I have done it:



<ComboBox ItemsSource="{Binding GetLinge, TargetNullValue='123456789', FallbackValue='123456789'}"/>  


In your case you would use the TargetNullValue to populate the values. The 10 might be a bit tricky as the string is IEnumerable so it will pick single characters from the array. But I think this will push you in the right direction.



OPTION 2

Another option is to modify your public void _fillLinge() method and let it return default values if there aren't any found.



OPTION 3

Another Option would be to use a converter which would then supply the default items instead of modifying the public void _fillLinge() method.

The choice is yours.






share|improve this answer


























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53424170%2fcombobox-in-wpf-unable-to-add-hardcode-values-with-database-values%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    OPTION 1

    Display a hardcoded set of values:

    Here is how I have done it:



    <ComboBox ItemsSource="{Binding GetLinge, TargetNullValue='123456789', FallbackValue='123456789'}"/>  


    In your case you would use the TargetNullValue to populate the values. The 10 might be a bit tricky as the string is IEnumerable so it will pick single characters from the array. But I think this will push you in the right direction.



    OPTION 2

    Another option is to modify your public void _fillLinge() method and let it return default values if there aren't any found.



    OPTION 3

    Another Option would be to use a converter which would then supply the default items instead of modifying the public void _fillLinge() method.

    The choice is yours.






    share|improve this answer






























      0














      OPTION 1

      Display a hardcoded set of values:

      Here is how I have done it:



      <ComboBox ItemsSource="{Binding GetLinge, TargetNullValue='123456789', FallbackValue='123456789'}"/>  


      In your case you would use the TargetNullValue to populate the values. The 10 might be a bit tricky as the string is IEnumerable so it will pick single characters from the array. But I think this will push you in the right direction.



      OPTION 2

      Another option is to modify your public void _fillLinge() method and let it return default values if there aren't any found.



      OPTION 3

      Another Option would be to use a converter which would then supply the default items instead of modifying the public void _fillLinge() method.

      The choice is yours.






      share|improve this answer




























        0












        0








        0







        OPTION 1

        Display a hardcoded set of values:

        Here is how I have done it:



        <ComboBox ItemsSource="{Binding GetLinge, TargetNullValue='123456789', FallbackValue='123456789'}"/>  


        In your case you would use the TargetNullValue to populate the values. The 10 might be a bit tricky as the string is IEnumerable so it will pick single characters from the array. But I think this will push you in the right direction.



        OPTION 2

        Another option is to modify your public void _fillLinge() method and let it return default values if there aren't any found.



        OPTION 3

        Another Option would be to use a converter which would then supply the default items instead of modifying the public void _fillLinge() method.

        The choice is yours.






        share|improve this answer















        OPTION 1

        Display a hardcoded set of values:

        Here is how I have done it:



        <ComboBox ItemsSource="{Binding GetLinge, TargetNullValue='123456789', FallbackValue='123456789'}"/>  


        In your case you would use the TargetNullValue to populate the values. The 10 might be a bit tricky as the string is IEnumerable so it will pick single characters from the array. But I think this will push you in the right direction.



        OPTION 2

        Another option is to modify your public void _fillLinge() method and let it return default values if there aren't any found.



        OPTION 3

        Another Option would be to use a converter which would then supply the default items instead of modifying the public void _fillLinge() method.

        The choice is yours.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 22 '18 at 9:21

























        answered Nov 22 '18 at 8:45









        XAMlMAXXAMlMAX

        1,8731920




        1,8731920
































            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53424170%2fcombobox-in-wpf-unable-to-add-hardcode-values-with-database-values%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            mysqli_query(): Empty query in /home/lucindabrummitt/public_html/blog/wp-includes/wp-db.php on line 1924

            How to change which sound is reproduced for terminal bell?

            Can I use Tabulator js library in my java Spring + Thymeleaf project?