This Code has a problem , that I don't know what is that . this code must Delete row of gridview when selected. I set AutoGenerateSelectButton = true then write this Code that don't work and have Exception from foreach.
protected void IDeletebtn_Click(object sender, EventArgs e)
{
foreach (GridViewRow Items in InboxGrv.SelectedRow)
{
var delete = from del in MDB.Messages
where del.Subject == Items.Cells[0].Text.ToString()
select del;
foreach (var Item in delete)
{
MDB.Messages.DeleteOnSubmit(Item);
}
MDB.SubmitChanges();
}
}
Exception :
foreach statement cannot operate on variables of type 'System.Web.UI.WebControls.GridViewRow' because 'System.Web.UI.WebControls.GridViewRow' does not contain a public definition for 'GetEnumerator' C:\Documents and Settings\Tehrani\Desktop\MessageAdminPage\ADMIN\Inbox.aspx.cs 87 9 C:...\MessageAdminPage\