how to respond to gridview's specific button event

Oct 26 2013 11:33 PM
I have a a gridview with one row. Row Contain Combobox text box and two button.
now i want to work on Button event which is inside of gridview i am using this .
if (e.RowIndex >= 0 && ((DataGridView)sender).Columns[e.ColumnIndex].GetType() == typeof(DataGridViewButtonColumn))
   {
      DataGridViewRow row = (DataGridViewRow)dataGridView1.Rows[0].Clone();
      dataGridView1.Rows.Add(row);
 
      MessageBox.Show(e.ColumnIndex.ToString()+' '+e.RowIndex);
   }
It working fine but the problem is; it is working on both button click event. plus as i try to write intextbox (which inside of gridview) it also get fire.

Answers (2)