ASP.NET customValidator accessing items from template column of combobox

4 posts, 0 answers
  1. JD.
    JD. avatar
    37 posts
    Member since:
    Aug 2012

    Posted 28 Sep 2011 Link to this post

    Hi,

    I have a Client Side CustomValidator Control, Is there a way to access selected item's CityCode value from comboxbox's itemtemplate. using client side javascript
    --JD
    ( Please advice, some easy workable workaround )

    <telerik:RadComboBox ID="RadComboBox2" Runat="server" TabIndex="3"
                          DropDownWidth="320px"
                           HighlightTemplatedItems="true"
                             DataSourceID="EDSStateList" DataTextField="StateName"
                            DataValueField="StateCode" SelectedValue='<%# Bind("FK_StateCode") %>'>
                             <HeaderTemplate>
                              <ul>
                                 <li class="col1">StateName</li>
                                 <li class="col2">CityName</li>
                                 <li class="col3">CityCode</li>
                             </ul>
                             </HeaderTemplate>
      
                             <ItemTemplate>
                                 <ul>
                                     <li class="col1">
                                         <%# DataBinder.Eval(Container.DataItem, "StateName")%></li>
                                     <li class="col2">
                                         <%# DataBinder.Eval(Container.DataItem, "CityName")%></li>
                                     <li class="col3">
                                         <%# DataBinder.Eval(Container.DataItem, "CityCode") %></li>
                                 </ul>
                             </ItemTemplate>
      
                             <FooterTemplate>
                 
                            </FooterTemplate>
      
                        </telerik:RadComboBox>
  2. Vasil
    Admin
    Vasil avatar
    1547 posts

    Posted 29 Sep 2011 Link to this post

    Hi,

    You could use get_selectedItem function of the RadComboBox's JavaScript object to get the selected item. And then use findControl of the method to find child controls of RadComboBoxItem object.
    Check these resources for more information:
    http://www.telerik.com/help/aspnet-ajax/combobox-client-side-radcombobox.html
    http://www.telerik.com/help/aspnet-ajax/combobox-client-side-radcomboboxitem.html
    http://www.telerik.com/help/aspnet-ajax/combobox-templates-accessing-controls.html

    Regards,
    Vasil
    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. JD.
    JD. avatar
    37 posts
    Member since:
    Aug 2012

    Posted 29 Sep 2011 Link to this post

    HI

    Below line give error.

       function APICodeValidate(sender, args) {
      
    // Function APICodeValidate is a CustomValidator Control, attached to a Textbox which is
    // inside FormTemplate of a RadGrid Control 
    which should check RadComboBox2's Selected Row value,
    // RadComboBox2 is a MultiColumn also inside FormTemplate.  
    // The Value to access and compare is 3rd Column of a MultiColumn Template
    // based on seleted combox row.
                   var combo = $find("<%= RadComboBox2.ClientID %>");
                   var i = 0;
               }

    Because RadComboBox2 is within Grid Control's FormTemplate available during Insert or Edit.
  5. Vasil
    Admin
    Vasil avatar
    1547 posts

    Posted 29 Sep 2011 Link to this post

    Hello,

    Check these help topic about accessing cells inside the grid's rows:
    http://www.telerik.com/help/aspnet-ajax/grid-accessing-cells-and-rows.html
    http://www.telerik.com/help/aspnet-ajax/grid-griddataitem-findcontrol.html

    A bit more easier would be to if you have only one combo on your page (when you have only one insert or form) that you want to access. You could remember it in one variable during it's load and then use it later when you need. This approach will work even if the combo is inside an grid.

    <script type="text/javascript">   
    var MyComboBox = null;
     
    function ComboBoxClientLoad(sender, object)
    {
      MyComboBox = sender;
    }
    </script>
     
     ........
     ........
     ........
     
    <telerik:RadComboBox runat="server" OnClientLoad="ComboBoxClientLoad">

    Kind regards,
    Vasil
    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
Back to Top