——此文章摘自《ASPNET +SQL Server网络应用系统开发案例精解》定价¥特价¥ 详细>>http://tracklinktechcn/?m_id=dangdang&a_id=A&l=&l_type= width= height= border= nosave> ()响应编辑事件 //单击编辑按钮所触发的事件 public void STmyGrid_edit(object source SystemWebUIWebControlsDataGridCommandEventArgs e) { //获取DataGrid所要编辑的项的索引 STmyGridEditItemIndex=(int)eItemItemIndex; BindGrid(); } ()响应更新事件 获取编辑状态下的文本框中的值并把它们赋值给更新语句的参数然后执行SQL语句退出编辑状态并重新显示数据 //单击更新按钮所触发的事件 public void STmyGrid_update(object source SystemWebUIWebControlsDataGridCommandEventArgs e) { //创建更新连锁店信息的sql语句 string STstrsql=update STDep set STDepName = @STDepName STDepMaster = @STDepMaster STDepInfo = @STDepInfo where STDepID = @STDepID; //创建数据库的SqlCommand对象 SqlCommand STcmd=new SqlCommand(STstrsqlSTconn); try { //向SqlCommand对象添加参数 STcmdParametersAdd(new SqlParameter(@STDepIDSqlDbTypeInt)); STcmdParametersAdd(new SqlParameter(@STDepNameSqlDbTypeVarChar)); STcmdParametersAdd(new SqlParameter(@STDepMasterSqlDbTypeVarChar)); STcmdParametersAdd(new SqlParameter(@STDepInfoSqlDbTypeVarChar)); string stupdatetext=((TextBox)eItemCells[]Controls[])Text ; //向参数赋值 STcmdParameters[@STDepName]Value=stupdatetext; stupdatetext=((TextBox)eItemCells[]Controls[])Text; STcmdParameters[@STDepMaster]Value=stupdatetext; stupdatetext=((TextBox)eItemCells[]Controls[])Text; STcmdParameters[@STDepInfo]Value=stupdatetext; right>[http://developcsaicn/dotnet_ASP/htm>] [] [http://developcsaicn/dotnet_ASP/htm>] [http://developcsaicn/dotnet_ASP/htm>] [http://developcsaicn/dotnet_ASP/htm>] |