如何实现在页面上做按钮删除datagrid中checkbox被选中的行

解决方案 »

  1.   

    System.Web.UI.WebControls.CheckBox chkExport;
    System.Collections.ArrayList oExArgs = new System.Collections.ArrayList();
    string sID;
    string id;
    foreach(DataGridItem oDataGridItem in dgMain.Items)
    {
    chkExport = (CheckBox)oDataGridItem.FindControl("chkExport");
    if( chkExport.Checked)
    {
    sID = ((HtmlInputHidden)oDataGridItem.FindControl("SelectedID")).Value;
    oExArgs.Add(sID);
    }
    }
    int i = 0;
    for( i = 0;i<oExArgs.Count;i++)
    {
    if (oExArgs[i]!=null)
    {
    id=oExArgs[i].ToString().Trim();
    string s="DELETE FROM news_type WHERE id ="+id;
    myDBOperate.ExcSQL(s,2); }
    else
    {

    Response.Write("<script laguage='javascript'>history.back();</script>");
    }


    } Response.Redirect("type_manager.aspx");