It throws an object ref error - the item in the list just doesn't appear to being stored or referenced in anyway.
On Apr 1, 12:35 pm, Guilherme Utrabo <[email protected]> wrote: > Try using lstTest.SelectedItem > > On 31 March 2010 16:51, 50cal <[email protected]> wrote: > > > > > Hi All, > > > I am attempting to add elements to a list box and then retrieve the > > selected value of an element as required. > > > List box is populated by (SQL Query Pulls Relevant Data): > > > while (reader1.Read()) > > { > > ListItem myItem = new > > ListItem((reader1["Type"].ToString() + " (" + > > reader1["String"].ToString() + ")"), reader1["id"].ToString()); > > lstTest.Items.Add(myItem); > > } > > > I've Tried just using > > > string itemVal = lstTest.SelectedValue.toString(); > > > to return the selected value, But no value is returned. I've also > > tried turning on AutoPostBack however when a value is selected the > > listbox is reset/refreshed and I still cannot retrieve the selected > > value. > > > Any help would be appreciated. > > > -- > > To unsubscribe, reply using "remove me" as the subject.
