Witam. Mam projekt napisany w vs2010. Mam w nim DropDownList i podpięte zdrarzenie SelectIndexChanged. W obsłudze zdarzenia rzutuję sobie sender na DropDownList i próbuję pobrać SelectedItem, wygląda to tak:
DropDownList ddl = sender as DropDownList;
string str = ddl.SelectedItem.ToString();
i ten kod wywala mi błąd:
'DropDownList' does not contain a definition for 'SelectedItem' and no extension method 'SelectedItem' accepting a first argument of type 'DropDownList' could be found (are you missing a using directive or an assembly reference?).
W momencie gdy odwołuję się bezpośrednio do DropDownList (nie przez sender) to wszystko jest ok. Pracuję teraz na win7, w momencie jak pisałem ten kod pracowałem na win 2k8 i wtedy hulało bez problemów. Może mi to ktoś wyjaśnić? Dzięki.