This is a migrated thread and some comments may be shown as answers.

ComboBox not passing selected value to content page

1 Answer 87 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Richard
Top achievements
Rank 1
Richard asked on 29 Nov 2010, 03:54 AM
I am new to this stuff so I may be the issue.  I have a master page and content page.  On the master page I have a combobox.
<telerik:RadComboBox ID="cbBox" runat="server" AutoPostBack="True" 
                         Height="120px" 
                        ErrorMessage="No Items Available" Sort="Ascending">
 </telerik:RadComboBox>

 

 Fill by code behind(c#):

 

using (WorkFlowEntities items = new WorkFlowEntities())
 {
   {
     this.cbBox.DataSource = from c in items.vw_UserAuth
where c.DomainName== "me"                                                         select new { c.Name, c.Item };
 this.cbProject.DataTextField = "Name";
 this.cbProject.DataValueField = "Item";
 this.cbProject.DataBind();
 this.cbProject.Items.Insert(0, new RadComboBoxItem("Select a item", string.Empty));
 }
}

 All of this works fine.  I am trying to access the combobox from a content page but it always returns "" not null though.  I am using this code to get the values:
 

 

private string getSelectedProject()
       {
           RadComboBox masterCombo = (RadComboBox)Master.FindControl("cbBox");
           if (masterCombo != null)
           {
               return masterCombo.SelectedValue.ToString();
           }
           else
           {
               return null;
           }
       }

I know there is data being return because i tried hard coding the selected value.

 

 

 

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 29 Nov 2010, 11:15 AM
Hello Richard,

Your code worked perfectly at my end when the RadComboBox placed directly on master page . I suppose the control (RadComboBox ) is nested inside any other control. If so you need to access the container control first and then access the control (using FindControl method).

Thanks,
Princy.
Tags
ComboBox
Asked by
Richard
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or