From a combo box I use the SelectedValue property as a parameter to a query
from which I populate a ListBox
private void cmbxCategory_Se lectedValueChan ged(object sender, EventArgs e)
{
string theCatId = cmbxCategory.Se lectedValue.ToS tring();
var getSubCat =
from sc in dataSet.SubCate gory
where (theCatId == sc.S_CatId)
select sc.S_Descriptio n; // get the Description
lsbxSubCat.Data Source = getSubCat.ToLis t(); // put Description
in ListBox
}
I then want to get the data from the ValueMember of the ListBox's selected
item.
However, using MessageBox to display my required result is showing "".
private void lsbxSubCat_Sele ctedValueChange d(object sender,
EventArgs e)
{
string theSubCatId = lsbxSubCat.Sele ctedValue.ToStr ing(); // get
the Id for the Description
MessageBox.Show (theSubCatId);
}
Can anyone point out any obvious errors?
Thanks
from which I populate a ListBox
private void cmbxCategory_Se lectedValueChan ged(object sender, EventArgs e)
{
string theCatId = cmbxCategory.Se lectedValue.ToS tring();
var getSubCat =
from sc in dataSet.SubCate gory
where (theCatId == sc.S_CatId)
select sc.S_Descriptio n; // get the Description
lsbxSubCat.Data Source = getSubCat.ToLis t(); // put Description
in ListBox
}
I then want to get the data from the ValueMember of the ListBox's selected
item.
However, using MessageBox to display my required result is showing "".
private void lsbxSubCat_Sele ctedValueChange d(object sender,
EventArgs e)
{
string theSubCatId = lsbxSubCat.Sele ctedValue.ToStr ing(); // get
the Id for the Description
MessageBox.Show (theSubCatId);
}
Can anyone point out any obvious errors?
Thanks
Comment