Hi,
Please rechange the your code as follows.
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
SqlDataAdapter ad = new SqlDataAdapter("select *from Reg where name='" + comboBox1.SelectedItem.ToString()+ "'", con);
DataSet ds = new DataSet();
ad.Fill(ds, "Reg");
dataGridView1.DataSource = ds.Tables["Reg"].DefaultView;
if(ds.Tables["Reg"].Rows.Count > 0)
{
textBox1.Text = ds.Tables["Reg"].Rows[0]["Email"].ToString();
}
else
{
textBox1.Text="";
}
}
If the selected combo box value is not there in database,it will return zero rows.
Thats why you are getting this kind of error.
I hope it will solve your problem.
Regards,
Kiran.