I am trying to fetch the selected value of the listbox. When I actually try LstGroup1.SelectedItem
I get the value { BoothID = \"4\", BoothName = \"HP\" }
I think, you should try one of the following : //EDIT : This solution only works, if Booth
is a class/struct
var myBooth = LstGroup1.SelectedItem as Booth;
String id =myBooth.BoothID;
String name=myBooth.BoothName:
or use a generic list with a different type :
public List BoothsInGroup1 { get; set; }
....
var myBooth = LstGroup1.SelectedItem;
String id =myBooth.BoothID;
Stringname=myBooth.BoothName:
And if Booth
isn't a class yet, add a new class:
public class Booth
{
public int BoothID { get; set; }
public String BoothName { get; set; }
}
So u can use it in your generic list, an you can fill it after databasereading
BoothsInGroup1.Add(new Booth
{
BoothID = Convert.ToInt32(da["BoothID"]),
BoothName = da["BoothName"].ToString()
});