Hello all,
I created a UserControl with ObjectDataSource + ASPxGridView. SelectMethod of ObjectDataSource I set the dynamicly depending on public parameter of UserControl:
private int _companyID = -1;
public int CompanyID
{
get { return _companyID; }
set
{
_companyID = value;
dsPersons.SelectMethod = "GetPersonsByCompany";
dsPersons.SortParameterName = "sort";
dsPersons.SelectParameters.Clear();
dsPersons.SelectParameters.Add("companyID", DbType.Int32, value.ToString());
}
}
When I use my control on Page like this:
<uc:PersonsManager ID="personsManager" runat="server" CompanyID="2" />
or put it in another ASPxGridView like this:
<dxwgv:ASPxGridView ID="gridViewCompany" runat="server" DataSourceID="dsCompany" KeyFieldName="ID" Width="100%"
AutoGenerateColumns="false">
<Columns>
<dxwgv:GridViewDataColumn>
<DataItemTemplate>
<uc:PersonsManager ID="personsManager" runat="server" CompanyID='<%# Bind("ID") %>' />
</DataItemTemplate>
</dxwgv:GridViewDataColumn>
</Columns>
</dxwgv:ASPxGridView>
All works fine, but I wanna to declare Control parameter from code-behind:
<uc:PersonsManager ID="personsManager" runat="server" />
and then on Page_Load:
personsManager.CompanyID = 2;
And if I use previous declaration then I can see only first load of UserControl's ASPxGridView with some data, because any manipulation will cause error on HtmlRowCreated event of UserControl's ASPxGridView:
The Select operation is not supported by ObjectDataSource 'dsPersons' unless the SelectMethod is specified.
Why is this happening?
Thanks.