how can i delete data in gridview and database (windows applications)

Posted by Sudheep.grandhe under C# on 1/9/2012 | Points: 10 | Views : 3516 | Status : [Member] | Replies : 2
Hi,


presently i am developing windows forms.my requirment is i want to delete data from gridview and database.for this i am having a form named like "new invoice" in this i am using two tables those are.tbl_report1 ,tbl_report2.tbl_report2 columns are:invoiceno(PK),companyname,companyaddress,orderno,ondate,invoicedate,amountstatus,netvat,netamount,tamount
tbl_report1 columns are:invoiceno(Fk),particulars,quantity,perprice,amount,orderno,invoicedate,ondate,companyname,invoiceid.

based on the above information how can i solve my issue.please do the needful.


private void btn_delete_Click_1(object sender, EventArgs e)
{
//if (!Validation())
// return;
if (this.GridView1.SelectedRows.Count > 0)
{
GridView1.Rows.RemoveAt(this.GridView1.SelectedRows[0].Index);
MessageBox.Show("Row Deleted");
}
}

Best,
Sudheep.



Responses

Posted by: Blessyjees on: 1/9/2012 [Member] Bronze | Points: 25

Up
0
Down
Hi,

At the same time you can execute the database operation by passing the primary key of that particular row.

Blessy Baby
Digitalmesh Softech pvt Ltd
https://blessybaby.wordpress.com/

Sudheep.grandhe, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sudheep.grandhe on: 1/9/2012 [Member] Starter | Points: 25

Up
0
Down
Hi,

Thanks for replying to me.can you please provide some sample code.please do the needful.

Best,
Sudheep.

Sudheep.grandhe, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response