I have a listbox in an ASP.NET web application that stores a list of names. These names are bound to a database that stores the names and their associated IDs, and is referenced via LINQ to SQL. Whenever I attempt to delete a name from the list, I encounter
a FormatException because ListBox1.SelectedValue is "" (it should be an ID that is the value of a name). Any ideas about why this is happening? Thanks in advance!
protected void checkOutButton_Click(object sender, EventArgs e)
{
DataClasses1DataContext db = new DataClasses1DataContext();
var selectedID = int.Parse(ListBox1.SelectedValue);
tblNorthAttendee toDelete = db.tblNorthAttendees.Single(a => a.id == selectedID);
db.tblNorthAttendees.DeleteOnSubmit( toDelete );
db.SubmitChanges();
ListBox1.DataBind(); }
Go to the complete details ...