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.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
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>
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.
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.
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
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;
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();