How can I send 'ListBox selected item`s value' to LocalDatabase - Windows Phone

I have a listbox like this:

<toolkit:ListPicker Name="lstBoxBaseUnitOfMeasure" Width="100" Margin="0,4,0,0">
     <toolkit:ListPicker.Items>
          <TextBlock Text="EACH" Height="30"/>
          <TextBlock Text="GRAM" Height="30"/>
     </toolkit:ListPicker.Items>
</toolkit:ListPicker>

I would like to send selected item to Local Database like this:

private void AddProduct_Click(object sender, RoutedEventArgs e)
    {
        TblProductsToOrder newProductToOrder = new TblProductsToOrder
            {
                OrderNId = selectedID,
                Quantity = int.Parse(txtQuantity.Text),
                **BaseUnitOfMeasure = ??????????????**
            };
    }

Answers


Assuming that BaseUnitOfMeasure property is of type String, you can try this way :

String selectedUnit = "";
if(lstBoxBaseUnitOfMeasure.SelectedItem != null)
{
    var selectedTextBlock = (TextBlock)lstBoxBaseUnitOfMeasure.SelectedItem;
    selectedUnit = selectedTextBlock.Text;
}
TblProductsToOrder newProductToOrder = new TblProductsToOrder
                                        {
                                            OrderNId = selectedID,
                                            Quantity = int.Parse(txtQuantity.Text),
                                            BaseUnitOfMeasure = selectedUnit
                                        };

ListPicker fires an event,SelectionChanged whenever a item is selected. You will need to listen to that event

<toolkit:ListPicker Name="lstBoxBaseUnitOfMeasure" Width="100" Margin="0,4,0,0" SelectionChanged="listPicker_SelectionChanged">
     <toolkit:ListPicker.Items>
          <TextBlock Text="EACH" Height="30"/>
          <TextBlock Text="GRAM" Height="30"/>
     </toolkit:ListPicker.Items>
</toolkit:ListPicker>


 private void listPicker_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (lstBoxBaseUnitOfMeasure.SelectedItem != null)
            {
                var texBlock = (TextBlock) lstBoxBaseUnitOfMeasure.SelectedItem;
                selectedUnit = texBlock.Text;
                TblProductsToOrder newProductToOrder = new TblProductsToOrder
                    {
                        OrderNId = selectedID,
                        Quantity = int.Parse(txtQuantity.Text),
                        BaseUnitOfMeasure = selectedUnit
                    };
            }
        }

Need Your Help

Oracle: Selecting all records where the table's date fields' hour and minute value are set to certain value

database datetime select oracle10g

I have a table in a Oracle database containing a date field EXPIRYDATE. I would need to select all records from the table, where the hour and minute portion of the date field are set to 0 (i.e. mid...

Which programming languages support TRUE cross-platform interoperability of software written on them?

programming-languages interop cross-platform

First of all, I would NOT like to incite any fanboy or flaming wars, like my language is better than yours.