如何使用存储过程从数据列表中删除所选项目? [英] how to delete selected items from datalist using stored procedure?

查看:72
本文介绍了如何使用存储过程从数据列表中删除所选项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hi如何使用存储过程从数据列表中删除所选项目... ???
谁能帮忙???

hi how to delete selected items from datalist using stored procedure...???
can any one help???

推荐答案

亲爱的法哈德,

一旦从数据列表中选择了所有项目,然后尝试在其上应用for循环或foreach循环,以获取从列表中选择的项目的所有ID,并编写存储过程以通过发送以下命令删除特定记录在SQL Proc中作为参数选择的项目的ID.

希望你能理解.

谢谢
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


使用与下面的代码相同的

Use same as below code

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
      }
    }




对于转发器,对于gridview一样
foreach(grdDetail.Rows中的GridviewRow grd)
{
CheckBox chkSelect =(CheckBox)grd.FindControl("chkSelect");

现在,像上面一样更改您的代码.

如果有任何问题,可以与我联系.




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.


使用复选框选择多行,然后单击删除按钮.使用条件检查选择了哪些行,并将其写在循环中以检查多行.
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.
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();
}



有关更多详细信息:
http://msdn.microsoft.com/en-us/library/b7y72882%28v = vs.71%29.aspx [ ^ ]
希望对您有帮助.
并且,如果有帮助,别忘了将其标记为答案. :)



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. :)


这篇关于如何使用存储过程从数据列表中删除所选项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆