我录入了一个“是否正在使用”这个数据,是用CheckBox实现的!
DataGrid中显示这个字段显示的是“是“或”否“
加了个更新按钮,”是否正有使用“是模板列,EditItemTemplate是个 ,ItemTemplate是个 并绑定数据库中IsSection这个字段。
现在出现的问题是:DataGrid中显示的“是”,我编辑按钮不会转化为 ,然后更新不了 
路过的高手,帮帮小妹我......!!!!!!!

解决方案 »

  1.   

    没看懂
    EditItemTemplate是个 ,ItemTemplate是个 并绑
      

  2.   

    图片没显示出来,重新补充一下:
    我录入了一个“是否正在使用”这个数据,是用CheckBox实现的!
    DataGrid中显示这个字段显示的是“是“或”否“
    加了个更新按钮,”是否正有使用“是模板列,EditItemTemplate是个CheckBox框 ,ItemTemplate是个label, 并绑定数据库中IsSection这个字段。
    现在出现的问题是:DataGrid中显示的“是”,我编辑按钮会出现CheckBox框,但没有打勾 ,更新时出错
    路过的高手,帮帮小妹我......!!!!!!!
      

  3.   

    EditItemTemplate是个 ,ItemTemplate是个
    我编辑按钮不会转化为 -------------
    貌似没说清楚
      

  4.   

    那你想编辑那一列呢?你想编辑哪一列就把那一列放到EditItemTemplate中去。
      

  5.   

    早上机子出了点毛病,不能运行!这回来贴代码 private void DataGrid1_UpdateCommand(object source,System.Web.UI.WebControls.DataGridCommandEventArgs e)//更新
    {
    SqlConnection conn=new SqlConnection ("server=sf;uid=sa;pwd=;database=transys");
    conn.Open ();


    string str ="update adzzcsort_info set dzzcsort=@dzzcsort,Biller='"+Session["UserName"]+"', inputtime='"+ DateTime.Now +"',IsSection=@IsSection where id=@id";
    SqlCommand com=new SqlCommand (str,conn);
    com.Parameters .Add (new SqlParameter ("@id",SqlDbType.Int,4));
    com.Parameters.Add (new SqlParameter ("@dzzcsort",SqlDbType.NVarChar ,50));
    com.Parameters.Add(new SqlParameter("@IsSection",SqlDbType.Char,10));
    com.Parameters ["@id"].Value =DataGrid1.DataKeys [e.Item.ItemIndex ];
    com.Parameters ["@dzzcsort"].Value =((TextBox)e.Item.Cells[1].Controls[0]).Text;
        CheckBox CheckBox1=(CheckBox)e.Item.Cells[4].FindControl("CheckBox1").;         if (CheckBox1 != null)
    {

    if ( CheckBox1.Checked==true)
    {
    com.Parameters["@IsSection"].Value=1; }
    else
    {
    com.Parameters["@IsSection"].Value=0;
    }
    } TextBox CurrentTextBox=(TextBox)e.Item.Cells[1].Controls[0];
    if (CurrentTextBox.Text =="")
    {
    Page.Response .Write ("<script>alert('修改记录不能为空!')</script>");
    return;
    }
    com.ExecuteNonQuery ();
    conn.Close ();
    Page.Response .Write ("<script>alert('修改成功!')</script>");
    DataGrid1.EditItemIndex =-1;
    BindDataGrid();
    }
    出现的错误:未将对象引用设置到对象的实例。 
    说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.NullReferenceException: 未将对象引用设置到对象的实例。源错误: 
    行 184:
    行 185: TextBox CurrentTextBox=(TextBox)e.Item.Cells[1].Controls[0];
    行 186: if (CurrentTextBox.Text =="")
    行 187: {
    行 188: Page.Response .Write ("<script>alert('修改记录不能为空!')</script>");