刚学习.net,在网上发现都是03版vs的例子,请问一下有没有05 gridview下删除选定行的代码学习一下,谢谢了

解决方案 »

  1.   

    DataGridView.Rows[index]有删除方法
      

  2.   

    dataGridView1.Rows.RemoveAt和Remove都行呀。
      

  3.   

    http://dotnet.aspx.cc/article/A8EFC285-F0B1-4F8F-8E73-2B7D8724A47C/read.aspx
      

  4.   

    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            string url = Request.Url.ToString();
            if (null != Session["UserID"])
            {
                cSWUserId = Session["UserID"].ToString();
            }
            if (e.CommandName == "DeleteTheRecord")
            {
                Int32 startindex = Convert.ToInt32(e.CommandArgument);
                DataKey keyValue = GridView1.DataKeys[startindex];
                Int32 hubId = Convert.ToInt32(keyValue[0]);
                Int32 appointmentId = Convert.ToInt32(keyValue[1]);
                string clientid = keyValue[2].ToString();
                Int32 doctorTypeID = Convert.ToInt32(keyValue[3]);
                //执行删除操作
                bFPHN.UpdatePhnAlert(cSWUserId, hubId, appointmentId, doctorTypeID);
            }
        }
    供参考
      

  5.   

    我写了一个,但是运行没反应,大家帮忙看看在gridview里一列删除按钮,commandname=Delete;代码:  protected void GridView1_RowDeleting1(object sender, GridViewDeleteEventArgs e)
        {
            string id = GridView1.DataKeys[e.RowIndex].Values[0].ToString();
            string connStr = System.Configuration.ConfigurationManager.AppSettings["strConn"].ToString();
            string SqlStr = "delete from news where id=" + id;                   SqlConnection con = new SqlConnection(connStr);
                con.Open();
                DataSet myDataSet = new DataSet();
                string sql = "select* from news where shifouchakan = 0";
                SqlDataAdapter myCommand = new SqlDataAdapter(sql, con);            //填充DataSet     
                myCommand.Fill(myDataSet);            //关闭链接   
                GridView1.DataSource = myDataSet;            //绑定     
                GridView1.DataBind();
        
        }