foreach (int index in listBox1.SelectedIndices)
{
DataRowView view = listBox1.Items[index] as DataRowView;
string id = view["Course_Id"].ToString();
string name = view["Course_Name"].ToString();
listBox2.Items.Add(name);
rowIndexes.Add(index);
}
You have an issue there.Your assignment on rowindexes variable should return null.So when you try to reach it you 've got an exception.Check your index value with a MessageBox.Show(index); Method first.