Selected value is "" on PageLoad

5 posts, 1 answers
  1. Leszek
    Leszek avatar
    17 posts
    Member since:
    Sep 2009

    Posted 24 Sep 2010 Link to this post

    Hello,
    I have selected value = "" on page load i first time page is loaded.
    I've read that it is when

     

    EnableLoadOnDemand="true"

     


    but I've set this parameter to false
    Regards.
    Leszek
  2. Cori
    Cori avatar
    562 posts
    Member since:
    Jul 2010

    Posted 24 Sep 2010 Link to this post

    Can you show us what your RadComboBox declaration looks like?
  3. Leszek
    Leszek avatar
    17 posts
    Member since:
    Sep 2009

    Posted 30 Sep 2010 Link to this post

    sorry for delay. I was on the trip.

     

     

     

    <telerik:RadComboBox ID="RadCBProducts" Runat="server" AutoPostBack="true"
                        DataSourceID="LinqDSProducts" DataTextField="ProductName" 
                        DataValueField="IdProduct" Skin="Sunset" EnableLoadOnDemand="false">
                    </telerik:RadComboBox>

     

     

     

    protected void Page_Load(object sender, EventArgs e)
       {
           LinqDSPrices.Where = "Idproduct==" + RadCBProducts.SelectedValue;// this value is "" 
           RadGrid1.DataBind();
           RadGrid1.Rebind();
       }
    thanks
    Leszek

     

     

     

  4. Answer
    Cori
    Cori avatar
    562 posts
    Member since:
    Jul 2010

    Posted 30 Sep 2010 Link to this post

    Hello Leszek,

    Change your code to this:

    RadCBProducts.DataBind();
    LinqDSPrices.Where = "Idproduct==" + RadCBProducts.SelectedValue;// this value is "" 
    RadGrid1.DataBind(); 
    RadGrid1.Rebind();

    You need to bind the RadComboBox when accessing it in the Page_Load event because it has not be data bound yet. Thus, the reason why SelectedValue is blank.

    I hope that helps.
  5. Leszek
    Leszek avatar
    17 posts
    Member since:
    Sep 2009

    Posted 30 Sep 2010 Link to this post

    it is working now.
    Thanks.
    Leszek
Back to Top