GridViewObjectDataSource

http://topic.youkuaiyun.com/u/20070128/00/cd19d943-5835-422c-a839-fa2f555f5e8d.html
让我头痛的GridView Template DropdownList ObjectDataSource...强汗无法传参数

protected   void   GridView1_RowCommand(object   sender,   GridViewCommandEventArgs   e) 
{ 


  if   (e.CommandName   ==   "Update ") 
  { 
      string   StudentTitle   =   ((TextBox)GridView1.Rows[GridView1.EditIndex].FindControl( "uTitle ")).Text; 
      string   StudentBirthDay   =   ((TextBox) 
          GridView1.Rows[GridView1.EditIndex].FindControl( "uBirthDay ")).Text; 
      bool   StudentGender   =   ((RadioButtonList) 
          GridView1.Rows[GridView1.EditIndex].FindControl( "uGender ")).SelectedValue   ==   "男 "   ?   true   :   false; 
      string   StudentClassName   =   ((DropDownList) 
          GridView1.Rows[GridView1.EditIndex].FindControl( "uClassName ")).SelectedValue; 
      string   StudentID   =   GridView1.DataKeys[GridView1.EditIndex].Value.ToString(); 
      String   FileName   =   " "; 
      string   sql   =   " "; 
      String   PhotoPath   =   " "; 

          sql   =   "Update   Student   Set   Title=@Title,BirthDay   =   @BirthDay, "   ; 
          sql   +=   "Gender=@Gender,ClassName=@ClassName   Where   id=@id "; 
    
      SqlDataSource1.UpdateCommand   =   sql; 
      SqlDataSource1.UpdateCommandType   =   SqlDataSourceCommandType.Text; 

      SqlDataSource1.UpdateParameters.Add( "@Title ",   TypeCode.String,   StudentTitle); 
      SqlDataSource1.UpdateParameters.Add( "@BirthDay ",   TypeCode.DateTime,   StudentBirthDay); 
      SqlDataSource1.UpdateParameters.Add( "@Gender ",   TypeCode.Boolean,   StudentGender.ToString()); 
      if   (HasFileUploaded) 
      { 
          SqlDataSource1.UpdateParameters.Add( "@PhotoPath ",   TypeCode.String,   PhotoPath); 
      } 
      SqlDataSource1.UpdateParameters.Add( "@ClassName ",   TypeCode.String,   StudentClassName); 
      SqlDataSource1.UpdateParameters.Add( "@id ",   TypeCode.Int32,   StudentID); 

      SqlDataSource1.Update(); 
  } 
}     


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值