how to insert textblock in combobox in sql server

Javier R 211 Reputation points
2021-10-25T13:30:28.207+00:00

how to insert Textblock in Combobox in Sql server

<ComboBox Margin="10,20,0,0" x:Name="cbCategoria" Width="180">
                            <ComboBoxItem IsSelected="True">
                                <TextBlock x:Name="txtAlimento"  x:Uid="Alimento" Style="{StaticResource TextTextStyle}"/>
                            </ComboBoxItem>
                            <ComboBoxItem>
                                <TextBlock x:Name="txtMedioAmbiente"  x:Uid="MedioAmbiente"  Style="{StaticResource TextTextStyle}"/>
                            </ComboBoxItem>
                            <ComboBoxItem>
                                <TextBlock x:Name="txtParasito"  x:Uid="Parasito"  Style="{StaticResource TextTextStyle}"/>
                            </ComboBoxItem>
                            <ComboBoxItem>
                                <TextBlock x:Name="txtInsecto" x:Uid="Insecto"  Style="{StaticResource TextTextStyle}"/>
                            </ComboBoxItem>
                            <ComboBoxItem>
                                <TextBlock x:Name="txtMedicamento" x:Uid="Medicamentos"  Style="{StaticResource TextTextStyle}"/>
                            </ComboBoxItem>

                        </ComboBox>
Universal Windows Platform (UWP)
SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,777 questions
{count} vote

5 answers

Sort by: Most helpful
  1. Olaf Helper 40,901 Reputation points
    2021-10-26T06:06:51.433+00:00

    how to insert Textblock in Combobox in Sql server

    There are no kind of controls "in" SQL Server, only in application.

    code to insert into database

    No, it's not, in the code line you just assign a parameter for a query, which we don' know.


  2. Tom Phillips 17,716 Reputation points
    2021-10-29T11:49:41.17+00:00

    Just to be clear.

    SQL Server does not have UI. It is the back end database for storage.

    You are apparently asking a question about EF. Your question would be better asked on the EF forum.


  3. Javier R 211 Reputation points
    2021-11-04T20:30:29.547+00:00

    if I make an example how I take the code to the sql part: the problem I have is that the Textblock carries x:Uid=""

     cmd.Parameters.Add("@Category", SqlDbType.VarChar, 40).Value = cbCategoria
    

  4. Javier R 211 Reputation points
    2021-11-24T14:40:51.707+00:00

    when I choose one of the options of the Combobox I get the error: textblock was null. if I implement the code inside the bootn Accept me produces described above.

    ComboBoxItem Item = cbCategoria.SelectedItem as ComboBoxItem;
    
     TextBlock textBlock = Item.Content as TextBlock;
    

    if I do SelectionChanged it gives me error in the code that is the button Accept dciendo that declares textBlock.

    cmd.Parameters.Add("@category", SqlDbType.VarChar, 40).Value = textBlock.Text;
    
    0 comments No comments

  5. Javier R 211 Reputation points
    2021-12-07T10:25:52.87+00:00

    This is the application for comboboxes (ComboBoxitem). this is the release for the database

    <ComboBox x:Name="ComboBox1">
     <ComboBoxItem Content=""/>
    <ComboBoxitem Content=""/>
    </ComboBox>
    
    cmd.Parameters.Add("@category", SqlDbType.VarChar, 40).Value = cbComboBox1.SelectionBoxItem.ToString();