Sooo, i keep getting the error:
‘object’ does not contain a definition for ‘text’ and no extension
method ‘text’ accepting a first argument of type ‘object’ could be
found (are you missing a using directive or an assembly reference?)
for the below code- can anyone tell me why?
private void cboDataSets_SelectedIndexChanged(object sender, EventArgs e)
{
int cats = Int16.Parse(cboDataSets.SelectedItem.text);
lblGenerateSelection.Text = ("you have selected " + (20 - cats) + "cats you'd like to adopt");
}
cboDataSets.SelectedItem will return an object. If it really contains an object that has a .Text property, you have to cast it
If SelectedItem is really a string, you can do this instead:
If SelectedItem is an object that has overridden ToString() to display meaningful data, you can do this