4

I'm using multiple ObjectDataSources to fill ComboBox-fields in a FormView. The FormView is sort of generic, because it's appearance is different depending on it's category.

The category is defined in the url of the webpage. I'd like to create a class that filters the category out and expose several properties, that can be used to fill the ComboBox-fields.

Problem is, the default ObjectDataSource only got a property 'SelectMethod' to retrieve the data. With this class I'd like to create, it wouldn't be methods, but properties that will contain the data.

Is it someway, somehow still posible to assign a property to the 'SelectMethod' (or similar)? Is it better to use another approach?

Thanks.

2 Answers 2

9

Maybe I'm missing something. But if you are after to assign a property as SelectMethod, you have to set it as get_{Property Name}.

Sign up to request clarification or add additional context in comments.

Comments

0

If you are trying to assign a SelectMethod dynamicaly, you could do it:

// You say that the category comes from the Url, so, in Page_Load method

protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            // Get your QueryString variable
            if (Request["YourVariable"] != null)
            {
             string yourVariable = Request["YourVariable"].ToString();

              if (yourVariable == "CategoryX") {

                   ObjectDataSource1.SelectMethod = "SelectMethodFromCategoryX";

                   // and if you need to set SelectParameters to your ObjectDataSource
                   ObjectDataSource1.SelectParameters["pYourParameterNameForCategoryX"].DefaultValue = this.txtTest.Text;
              }

            }
        }
    }

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.