——此文章摘自《ASPNET +SQL Server网络应用系统开发案例精解》定价¥特价¥ 详细>>http://tracklinktechcn/?m_id=dangdang&a_id=A&l=&l_type= width= height= border= nosave> string STstrsql=update STUser set STNoAdmin = @STNoAdmin STNickName =@STNickName STUserName = @STUserName where STUserID = @STUserID; //创建SqlCommand对象对sql语句进行操作 SqlCommand STcmd=new SqlCommand(STstrsqlSTconn); try { //添加参数 STcmdParametersAdd(new SqlParameter(@STUserIDSqlDbTypeInt)); STcmdParametersAdd(new SqlParameter(@STNickNameSqlDbTypeVarChar)); STcmdParametersAdd(new SqlParameter(@STUserNameSqlDbTypeVarChar)); STcmdParametersAdd(new SqlParameter(@STNoAdminSqlDbTypeInt)); string stupdatetext=((TextBox)eItemCells[]Controls[])Text ; STcmdParameters[@STNickName]Value=stupdatetext; stupdatetext=((TextBox)eItemCells[]Controls[])Text; STcmdParameters[@STUserName]Value=stupdatetext; stupdatetext=((TextBox)eItemCells[]Controls[])Text; STcmdParameters[@STNoAdmin]Value=stupdatetext; STcmdParameters[@STUserID]Value=STmyGridDataKeys[(int)eItemItemIndex]; //打开连接 STcmdConnectionOpen(); //执行非查询 STcmdExecuteNonQuery(); STmyGridEditItemIndex=; } catch(SqlException ex) { throw ex; } //关闭连接 STcmdConnectionClose(); BindGrid(); } ()响应取消事件 //单击取消按钮所触发的事件 public void STmyGrid_cancel(object source SystemWebUIWebControlsDataGridCommandEventArgs e) { //获取DataGrid所要编辑的项的索引为 STmyGridEditItemIndex=; BindGrid(); } right>[http://developcsaicn/dotnet_ASP/htm>] [http://developcsaicn/dotnet_ASP/htm>] [http://developcsaicn/dotnet_ASP/htm>] [] [http://developcsaicn/dotnet_ASP/htm>] |