Hi
i am creating a windows app.
I have a delete button which works ok as below.
On the delete i would like to display a value from the cell as string s but i am aware the string s line will not work because item is not part of Eventargs e.
how can i display the value from columnname("ProviderName") for the currentcell selected?
many thanks
chris
i am creating a windows app.
I have a delete button which works ok as below.
On the delete i would like to display a value from the cell as string s but i am aware the string s line will not work because item is not part of Eventargs e.
how can i display the value from columnname("ProviderName") for the currentcell selected?
many thanks
chris
Code:
private void button1_Click(object sender, System.EventArgs e)
{
try
{
string s = e.Item.Cells[0].Text;
DialogResult dr=MessageBox.Show("Are you sure you want to delete this row ? " +s,
"Confirm deletion", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (dr ==DialogResult.Yes)
{
DataTable tbl=new DataTable("ProvidersDetail");
tbl=this.dsProviders.Tables[0];
// int i=dgProviders.iRowIndex;
int i=dgProviders.CurrentRowIndex;
tbl.Rows[i].Delete(); //delete the row
this.daProviders.Update(tbl); //update the table
dgProviders.Refresh();
// daProviders.Delete(dsProviders, tableName);
MessageBox.Show("Record Deleted successfully","Delete Record Confirmed",
MessageBoxButtons.OK,MessageBoxIcon.Information);
// dgProviders.Refresh();
}
}
catch (Exception E)
{
MessageBox.Show(E.ToString());
}
}