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

ComboBox Value Field

1 Answer 87 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Graeme
Top achievements
Rank 1
Graeme asked on 02 Mar 2012, 03:18 PM
Hello,
Using the combox box and populating it from the code behind, where I'm accessing our DAL. Its working ok, however there is no value field being rendered out to the HTML. So when it submits I'm getting the Text field submitted  for example '16th century' when I need the value field i.e. '34' (its id number). 
Here is a snippet of the rendered HTML:
<li class="rcbItem ">15th century</li><li class="rcbItem ">16th century</li>

Can some please explain why the ID field is not being rendered out here?
Many thanks,
Alan



Front End:
<label for="radComboPeriod">Time Period: </label>
            <telerik:RadComboBox ID="radComboPeriod" Width="300px" Height="140px" EmptyMessage="Type a Period" runat="server">
            <ExpandAnimation Type="OutBack" Duration="300" />
            <CollapseAnimation Type="InBack" Duration="300" />
            </telerik:RadComboBox>


Code Behind:

protected void Load_Periods(bool valpass)
        {
            //--   Create the connection- get the details and render them to the Datagrid.
            p2pDAL crudopsDAL = new p2pDAL();
            DataTable result = crudopsDAL.select_periods(); //use method to return all the cats 
            if (!IsPostBack)
            {
                radComboPeriod.DataSource = result;
                radComboPeriod.DataValueField = "PeriodID";
                radComboPeriod.DataTextField = "Period";
                string rebindValPer = (string)(Session["Period"]);
                if (valpass == false && rebindValPer != "Type a Period")
                {
                    radComboPeriod.SelectedValue = rebindValPer;
                }
                radComboPeriod.DataBind();
            }
        }

1 Answer, 1 is accepted

Sort by
0
Ivana
Telerik team
answered on 07 Mar 2012, 10:25 AM
Hello Graeme,

Every item of RadComboBox  is an object and not everything it contains is rendered on the page. You could easily access its content by using the client API of RadComboBoxItem object.

Could you provide us with some more information on what exactly is your scenario?

All the best,
Ivana
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
ComboBox
Asked by
Graeme
Top achievements
Rank 1
Answers by
Ivana
Telerik team
Share this question
or