Nahum
Nahum

Reputation: 7197

how to send datasource parameters to select function

EDIT

this is my new try:

now im getting ObjectDataSource 'MenuDataSource' could not find a non-generic method 'GetData' that has no parameters.

     <asp:ObjectDataSource 
     ID="GridDataSource"            
      SelectMethod="GetData"
      TypeName="Model.GridProvider"
      runat="server"  > 
     <SelectParameters>
        <asp:Parameter Name="MenuItemID" Type="Int32" DefaultValue="10"  />
      </SelectParameters>
      </asp:ObjectDataSource>


public int DbToAccess
    {
        get
        {
            return SiteMaster.Current_MenuItemID;
        }
    }


[DataObject(true)]
public static class MyMenuProvider
{
        [DataObjectMethod(DataObjectMethodType.Select)]
        public static HierarchicalCollection GetData(int inputMenuItemID)
        {
            return GetCollection(inputMenuItemID);
        }

}

how can I do this?

Upvotes: 1

Views: 914

Answers (2)

Nahum
Nahum

Reputation: 7197

answer is that I am stupid TypeName="Model.GridProvider" the class i put the select method on was MyMenuProvider

changed to

public static class GridProvider
{
    [DataObjectMethod(DataObjectMethodType.Select)]
    public static DataTable GetData(int MenuItemId)
    {
        return GuiCreators.getDataTable("");

    }


    public static void GetCommand(int id)
    {

    }


}

and alll my trouble where solved

Upvotes: 1

Mikey Mouse
Mikey Mouse

Reputation: 3098

You could use a public parameter, whose get call goes to the DataSource and gets back it's set parameter. Or even better would be a public parameter that stores it's value in a Session Variable, and both the Select Function and the DataSource access the Parameter. Something like this:

    public string MyParam
    {
           get
           {
                 return Session["MyParamStr"].ToString();
           } 
           set 
           {
                Session["MyParamStr"] = value;
           }
    }

Then in your Markup

    <asp:Parameter value='<%# MyParam %>' />

Upvotes: 1

Related Questions