1. 在设计页面中添加ObjectDataSource控件
  2. 右击该控件选择configue data source.
  3. 选择需要引用的方法所在的类,或者DLL
  4. 选择需要使用的select、update、insert或者delete方法
  5. 设置参数,一般使用control或者none
  6. 然后在ObjectDataSource的事件中添加selecting方法  

  调用方法如下:

 

        protected void uxObjectDataSourceChildDept_Selecting(object sender, ObjectDataSourceSelectingEventArgs e)
        {
            e.InputParameters[
"r"= "2333";//r为前面设置的变量参数
            
//uxObjectDataSourceChildDept.DataBind()//该方法可以用于调用selecting方法
否则只有在页面绑定时才调用selecting方法
        }

 

 注:在第四步中需要选择出方法,必须在bll层中引用的的方法前面添加

 

[System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Select)]

 

如果是查询方法选择:DataObjectMethodType.Select

更新方法:DataObjectMethodType.Update

删除、添加如上。

相关文章:

  • 2022-02-07
  • 2022-12-23
  • 2021-09-12
猜你喜欢
  • 2021-08-22
  • 2021-10-28
  • 2021-08-05
  • 2021-06-10
  • 2021-08-16
  • 2021-10-09
相关资源
相似解决方案