Pregunta

I have my ObjectDataSource enstantiated like so:

<asp:ObjectDataSource ID="x" runat="server" InsertMethod="xx"
    SelectMethod="xxx" TypeName="xxxx"
    UpdateMethod="xxxxx">

Select, insert, update methods do as you would expect; Select all data, insert data and update data. My question is, is there a way I can assign another method e.g. a second select which selects different data or maybe a deleteMethod?

¿Fue útil?

Solución

YES, you can. For any operation there is always an event raised before the operation is actually performed and one event after performing the operation.

So, in your case, it is select operation. the event raised just before this operation will be x.Selecting.

Set this event handler in .aspx as

<asp:ObjectDataSource ID="x" runat="server" InsertMethod="xx"
SelectMethod="xxx" TypeName="xxxx"
UpdateMethod="xxxxx" OnSelecting="x_Selecting">

Now, in this Selecting Event Handler change the select method dynamically, where 'x' is the ID of your object DataSource.

protected void x_Selecting()
{ x.SelectMethod="My_new_SelectMethod";
}

When select operation is performed, this new method will be used and then x.Selected event will get raised.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top