Delete a seleted row from a DataGridview using c# windows application

Posted by Sudheep.grandhe under Sql Server on 12/16/2011 | Points: 10 | Views : 3169 | Status : [Member] | Replies : 2
Hi,

i want to Delete a seleted row from a DataGrid using c# windows application.for that i have two tables tbl_report1,tbl_report2

tbl_report1 columns:invoiceno(FK),particulars,quantity,perprice,amount,compname,invoicedate,ondate,orderno,invoiceid.

tbl_report2 columns:compname,compaddress,invoiceno(PK),orderno,ondate,invoicedate,amountstatus,netamount,netvat,tamount

from above two tables i have to design a query for delete and update.based on invoiceno.please do the needful.

Best,
Sudheep.



Responses

Posted by: Sampath1750 on: 12/16/2011 [Member] Starter | Points: 25

Up
0
Down
First u write invoiceid in Datakeynames and write invoiceid in ur query.
Then
protected void grdProdTran_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
try
{
string InvoiceId = grdProdTran.DataKeys[e.RowIndex].Values[0].ToString();
//Here write ur delete statement Query using InvoiceId
}
Catch(Exception){}
}


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

Posted by: Arefin on: 12/19/2011 [Member] Starter | Points: 25

Up
0
Down
Ye, you can follow Sampath1750 code...

Thanks,
Arefin

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

Login to post response