Wednesday, 5 June 2013

How to get celltext values on text changed in Gridview asp.net C# Windows based.

Page load { dataGridView1.EditingControlShowing += new DataGridViewEditingControlShowingEventHandler(dataGridView1_EditingControlShowing); } -------------------- private void dataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { TextBox tx = e.Control as TextBox; DataGridViewTextBoxCell cell = (DataGridViewTextBoxCell)dataGridView1.CurrentCell; if (tx != null && cell.OwningColumn == dataGridView1.Columns[0]) { tx.TextChanged += new EventHandler(tx_TextChanged); } } void tx_TextChanged(object sender, EventArgs e) { string rate; TextBox tb = (TextBox)sender; if (!string.IsNullOrEmpty(tb.Text)) rate = tb.Text; else rate = ""; // double qty = Convert.ToDouble(dataGridView1.CurrentRow.Cells[0].Value); // dataGridView1.CurrentRow.Cells[2].Value = qty * rate; } }

No comments:

Post a Comment