开发者

Pass a this.property to ObjectDataSource

A user control contains a ListView, ObjectDataSource and a CustomerID property, is there a way to pass CustomerID to ObjectDataSource.

it seems ControlParameter does not fix the problem.

Regards开发者_如何学JAVA


ControlParameter must be used for to get a parameter from a Control. To get a parameter from a property you have to get it from code behind:

<asp:ObjectDataSource OnSelecting="OdsOnSelecting" .... >
   <SelectParameters>
      <asp:Parameter Name="CustomerID" />
   </SelectParameters>
</asp:objectDataSource>

protected void OdsOnSelecting(object sender, ObjectDataSourceMethodEventArgs e) {
    e.InputParameters["CustomerID"] = CustemerID;
}


Respond to this event:

http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.objectdatasource.objectcreating.aspx


Try creating an attribute/property for the usercontrol in question, THEN do what is mentioned in the two post before this one...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜