表news 
字段:userID, title,addtime
表dirn
字段:userid,username以上是在girdview中显示的内容请问删除语句和更新该如何写?

解决方案 »

  1.   

    改下面相应的代码就好了
    protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            GridViewRow grv = GridView1.Rows[GridView1.EditIndex];
            TextBox tb = (TextBox)grv.FindControl("textbox1");
            TextBox id = (TextBox)grv.FindControl("textbox2");
            string cname = tb.Text;
            if(cname!="" & id.Text!="")
            {
                DB.Execute("update max_type set cname='"+cname+"' where id="+id.Text);
            }
            Thread.Sleep(1000);
            GridView1.EditIndex = -1;
            Bind();    }
    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "del")
            {
                string sql = "delete from max_type where id=" + e.CommandArgument;
                DB.Execute(sql);
                Thread.Sleep(1000);
                Bind();
            }
        }
    public void Bind()
        {
            GridView1.DataSource = DB.go("select * from max_type order by id desc");
            GridView1.DataBind();
        }
      

  2.   

    不是啊,两个表,我要SQL语句。