The run-time types of the cell contents are different for the different cells. One type is
DropDownList
or assignment-compatible with it, another type is not. When you dynamically down-cast it to an incompatible type, it throws this exception. Check up what is actually in the cell in question. As simple as that.
Generally, it can be good to check up a run-time type instead of blind-folded type casting. Something like that:
DropDownList list = GridView1.Rows[e.RowIndex].Cells[1].Controls[0] as DropDownList;
if (list != null)
postgdetails.Qua = list.SelectedItem.ToString();
else
MessageBox.Show("Oh no! Not again! :-)");
—SA