ANAY SHUKLA

ANAY SHUKLA

  • NA
  • 24
  • 463

Delete from Repeator

Jan 19 2018 12:22 AM
protected void rptlist_ItemCommand(object source, RepeaterCommandEventArgs e)
{
try
{
if (e.CommandName == "Del")
{
int paymentid = 0;
paymentid = Convert.ToInt32(((Label)rptlist.Items[0].FindControl("lblpaymentid")).Text);
SqlParameter[] Paramsdel = { new SqlParameter("@Mode","D"),
new SqlParameter("@paymentid",paymentid)
};
int Res = 0;
Res = JSQL.execStoredProcudure("sp_bank", Paramsdel);
if (Res > 0)
{
JRDMessage.UserMessage(this, "Data deleted Sucessfully ");
FillDetails();
bindDet();
}
}
}
catch (Exception ex)
{
}
}
 
This is my code i want to delete row from data using payment id but when ever i click on last row or middle row button for delete then it will deleted top row every time , how can i manage it. 

Answers (2)

0
Ajeesh

Ajeesh

  • 0
  • 268
  • 41.9k
Jan 19 2018 12:32 AM
You can try with below code
  1.  protected void rptlist_ItemCommand(object source, RepeaterCommandEventArgs e)  
  2.         {  
  3.             try  
  4.             {  
  5.                 if (e.CommandName == "Del")  
  6.                 {  
  7.                     int paymentid = 0;  
  8.                     //Change the code like below  
  9.                     //paymentid = Convert.ToInt32(((Label)rptlist.Items[0].FindControl("lblpaymentid")).Text);  
  10.                     Label lbl = e.Item.FindControl("lblpaymentid"as Label;  
  11.                     paymentid = Convert.ToInt32(lbl.Text);  
  12.                     SqlParameter[] Paramsdel = { new SqlParameter("@Mode","D"),new SqlParameter("@paymentid",paymentid)  
  13. };  
  14.                     int Res = 0;  
  15.                     Res = JSQL.execStoredProcudure("sp_bank", Paramsdel);  
  16.                     if (Res > 0)  
  17.                     {  
  18.                         JRDMessage.UserMessage(this"Data deleted Sucessfully ");  
  19.                         FillDetails();  
  20.                         bindDet();  
  21.                     }  
  22.                 }  
  23.             }  
  24.             catch (Exception ex)  
  25.             {  
  26.             }  
  27.         }  
 
Accepted Answer
0
ANAY SHUKLA

ANAY SHUKLA

  • 0
  • 24
  • 464
Jan 19 2018 12:56 AM
Yes it is working .
 
Thanks a lot