Click here to Skip to main content
15,912,897 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
hi how to delete selected items from datalist using stored procedure...???
can any one help???
Posted

Dear Fahad,

Once you have selected all the Items from the datalist then try to apply a for loop OR foreach loop on it fetch all the Id's of the item being selected from the list and write a stored procedure for deleting the particular record by sending the id of the item selected into the SQL Proc as Parameter.

hope you understood.

thanks
 
Share this answer
 
Comments
ythisbug 27-Dec-11 0:42am    
thanks buddy...can u give me the code or website address..??
Varun Sareen 27-Dec-11 1:12am    
Dear fahad,

Please refer to the answer given by Manish.

thanks
Use same as below code

C#
foreach (RepeaterItem rept in rptbom.Items)
    {
      CheckBox chkSelect = (CheckBox)rept.FindControl("chkSelect");
      Int64 fg_id = Convert.ToInt64(((HiddenField)rept.FindControl("hdnfg_id")).Value);
      if (chkSelect.Checked == true)
      {
        //Delete Procedure working here
      }
    }



It is for repeater same is for gridview
foreach (GridviewRow grd in grdDetail.Rows)
{
CheckBox chkSelect = (CheckBox)grd.FindControl("chkSelect");

Now Change your code same as above.

if you have any problem then you can contact with me.
 
Share this answer
 
Comments
ythisbug 27-Dec-11 1:08am    
how to do in datalist..i gave only link button to remove..
use check box to select multiple rows and after that when you will click on delete button. check using condition which rows are selected and write this in loop for check multiple rows.
C#
protected void DeleteAll_Click(object sender, System.EventArgs e)
{
   bool isDeleted;

   // Check each box and see if the item should be deleted.
   foreach (DataListItem anItem in DataList1.Items)
   {
      isDeleted =
         ((CheckBox)anItem.FindControl("Delete")).Checked;
      if (isDeleted)
      {
         // Add code here to delete the item, using anItem.ItemIndex.
      }
   }
   DataList1.DataBind();
}


for more in detail :
http://msdn.microsoft.com/en-us/library/b7y72882%28v=vs.71%29.aspx[^]
Hope this will help you.
And don't forget to mark as answer if it helps. :)
 
Share this answer
 
Check This Link


http://www.expertrating.com/courseware/DotNetCourse/DotNet-ASP.Net-6-1.asp


hope this will help u.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900