ItemTemplate, RadComboBox, MasterPage, User Control :(

3 posts, 1 answers
  1. Alper Ozgur
    Alper Ozgur avatar
    8 posts
    Member since:
    Mar 2010

    Posted 10 May 2010 Link to this post

    Hi;
    I added all could cause the problem that i live. Here is the problem... I have a page that has a masterpage. In this page I'm calling a webUserControl. There is a listview in webUserControl. And plan to has 3 or more RadComboBox in this usercontrol that will be related combos. When i fill the first combo everything works fine. But When I Select an item the SelectedIndexChanged event of first combo doesn't fires and i loose the selectedValue. I couldn't find where did i made a mistake.. Could you help?
    Here is the Codes...

     

    MASTER PAGE
     
    <telerik:RadScriptManager ID="rSManager" runat="server">
    </telerik:RadScriptManager>
    <telerik:RadAjaxManager ID="rAjaxManager" runat="server" DefaultLoadingPanelID="rLoadingPnl">
     <AjaxSettings>
      <telerik:AjaxSetting AjaxControlID="RadMenu1">
      </telerik:AjaxSetting>
     </AjaxSettings>
    </telerik:RadAjaxManager>
    <telerik:RadAjaxLoadingPanel ID="rLoadingPnl" runat="server" Skin="WebBlue" RegisterWithScriptManager="true">
    </telerik:RadAjaxLoadingPanel>
    ....
    .....
    PAGE
    <asp:Content ID="Content1" ContentPlaceHolderID="cph_Main" runat="Server">
    <%@ register tagprefix="Telerik" namespace="Telerik.Web.UI" assembly="Telerik.Web.UI" %>
    <link href="~/CSSClasses/CssForTelerikItems.css" type="text/css" rel="stylesheet" />
    <link href="~/CSSClasses/vision.css" type="text/css" rel="stylesheet" />
    <%@ register src="NewUserControls/Profile/KisiselBilgiler.ascx" tagname="Kisisel" tagprefix="ucKisisel" %>
    <%@ register src="NewUserControls/Profile/EgitimBilgileri.ascx" tagname="Egitim" tagprefix="ucEgitim" %>
    <%@ register src="NewUserControls/Profile/IsTecrubeleri.ascx" tagname="Tecrube" tagprefix="ucTecrube" %>
    <%@ register src="NewUserControls/Profile/IsTercihleri.ascx" tagname="Tercihler" tagprefix="ucTercih" %>
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
     <script type="text/javascript">
      function myContentClickHandler()
      {
       $find("<%= RadAjaxManager.GetCurrent(Page).ClientID %>").ajaxRequest("content");
      }
     </script>
    </telerik:RadCodeBlock>
    <telerik:RadAjaxManagerProxy ID="RadAjaxManagerProxy1" runat="server">
     <AjaxSettings>
      <telerik:AjaxSetting AjaxControlID="ProfileDockLayout">
       <UpdatedControls>
        <telerik:AjaxUpdatedControl ControlID="ProfileDockLayout" LoadingPanelID="rLoadingPnl" />
       </UpdatedControls>
      </telerik:AjaxSetting>
     </AjaxSettings>
    </telerik:RadAjaxManagerProxy>
    <telerik:RadDockLayout ID="ProfileDockLayout" runat="server" Skin="WebBlue" StoreLayoutInViewState="True">
     <div style="float: left;">
      <telerik:RadDockZone ID="Zone1" runat="server" Width="970px" Orientation="Vertical" MinHeight="100px">
       <telerik:RadDock ID="dockProfil" runat="server" Width="970px" Height="185px" EnableAnimation="true"
       EnableRoundedCorners="true" Resizable="true" Title="Profil Bilgileri" DockMode="docked"
       DefaultCommands="None">
        <ContentTemplate>....
        </ContentTemplate>
       </telerik:RadDock>
      </telerik:RadDockZone>
     </div>
     <div>
      <telerik:RadTabStrip ID="tabsOzgecmis" runat="server" MultiPageID="mPageOzgecmis" Skin="WebBlue">
       <Tabs>
        <telerik:RadTab Text="Kiisel Bilgilerim" PageViewID="pViewKisisel">
        </telerik:RadTab>
        <telerik:RadTab Text="Eitim Bilgilerim" PageViewID="pViewEgitim">
        </telerik:RadTab>
        <telerik:RadTab Text=" Tecrbelerim" PageViewID="pViewTecrube">
        </telerik:RadTab>
        <telerik:RadTab Text=" Tercihlerim" PageViewID="pViewTercih">
        </telerik:RadTab>
       </Tabs>
      </telerik:RadTabStrip>
      <telerik:RadMultiPage ID="mPageOzgecmis" runat="server">
       <telerik:RadPageView ID="pViewKisisel" runat="server">
        <ucKisisel:Kisisel ID="uscKisisel" runat="server" />
       </telerik:RadPageView>
       <telerik:RadPageView ID="pViewEgitim" runat="server">
        <ucEgitim:Egitim ID="uscEgitim" runat="server" />
       </telerik:RadPageView>
       <telerik:RadPageView ID="pViewTecrube" runat="server">
        <ucTecrube:Tecrube ID="uscTecrube" runat="server" />
       </telerik:RadPageView>
       <telerik:RadPageView ID="pViewTercih" runat="server">
        <ucTercih:Tercihler ID="uscTercihler" runat="server" />
       </telerik:RadPageView>
      </telerik:RadMultiPage>
     </div>
    </telerik:RadDockLayout>
    </div>
    </asp:Content>

    USER CONTROL
    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
    <link href="~/CSSClasses/CssForTelerikItems.css" type="text/css" rel="stylesheet" />
    <link href="~/CSSClasses/vision.css" type="text/css" rel="stylesheet" />
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
     <script type="text/javascript">
      function myContentClickHandler()
      {
       $find("<%= RadAjaxManager.GetCurrent(Page).ClientID %>").ajaxRequest("content");
      }
      function onKeyPressing(sender) {
       sender.allowOpenDropDown = true;
      }

      function onDropDownOpening(sender, eventArgs) {
       if (!sender.allowOpenDropDown || sender.get_text().length == 0)
        eventArgs.set_cancel(true);
      }

      function onItemsRequesting(sender, eventArgs) {
       if (sender.get_text().length == 0) {
        if (sender.get_dropDownVisible())
         sender.hideDropDown();
         eventArgs.set_cancel(true);
       }
      }

      function onBlur(sender) {
       sender.allowOpenDropDown =
       false;
      }

      </script>
    </telerik:RadCodeBlock>
    <telerik:RadAjaxManagerProxy ID="RadAjaxManagerProxy1" runat="server">
     <AjaxSettings>
      <telerik:AjaxSetting AjaxControlID="lViewOkul">
       <UpdatedControls>
        <telerik:AjaxUpdatedControl ControlID="lViewOkul" LoadingPanelID="rLoadingPnl" />
       </UpdatedControls>
      </telerik:AjaxSetting>
     </AjaxSettings>
    </telerik:RadAjaxManagerProxy>

    <telerik:RadListView ID="lViewOkul" runat="server" OnItemCommand="lViewOkul_ItemCommand"
    DataKeyNames="KAYITNO" OnItemDataBound="lViewOkul_ItemDataBound" OnItemCreated="lViewOkul_ItemCreated">
     <InsertItemTemplate>
     </InsertItemTemplate>
     <EditItemTemplate>
     </EditItemTemplate>
     <EmptyDataTemplate>
      <div style="float: left">
      vs vs vs vs.
      <asp:LinkButton ID="btnOkul" runat="server" Text="Ekle" CommandName="InitInsert"></asp:LinkButton>
      </div>
     </EmptyDataTemplate>
     <EmptyItemTemplate>
     </EmptyItemTemplate>
     <ItemTemplate>
      <table class="itemLabels">
       <tr>
        <td>
        Seviyeniz
        </td>
        <td>
        :
        </td>
        <td>
         <telerik:RadComboBox ID="ctlOgrenimSeviyesi" runat="server" Width="190px" EnableLoadOnDemand="true"
         ShowToggleImage="false" LoadingMessage="..." OnClientKeyPressing="onKeyPressing"
         OnClientDropDownOpening="onDropDownOpening" OnClientItemsRequesting="onItemsRequesting"
         OnClientBlur="onBlur" AutoPostBack="true">
         </telerik:RadComboBox>
        </td>
       </tr>
       <tr>
        <td>
        Okul Ad
        </td>
        <td>
        :
        </td>
        <td>
         <telerik:RadComboBox ID="cmbOkulAdi" runat="server" ChangeTextOnKeyBoardNavigation="true"
         AllowCustomText="true" ItemsPerRequest="20" Width="190px" EnableItemCaching="True"
         Height="150px" LoadingMessage="Ykleniyor..." MarkFirstMatch="True" ShowWhileLoading="False">
         </telerik:RadComboBox>
        </td>
        </tr>
        <tr>
        <td colspan="3">
         <asp:LinkButton ID="btnDuzenle" runat="server" Text="Gncelle" CommandName="Edit"></asp:LinkButton>
        </td>
       </tr>
      </table>
     </ItemTemplate>
    </telerik:RadListView>

    UserControl cs

    protected void Page_Load(object sender, EventArgs e)
    {
    RadProfile rp = new RadProfile();
     if (vwProfilData == null)
      vwProfilData = rp.ReadProfil(vwProfilData);
     lViewOkul.DataSource = vwProfilData.OgrGorduguOkulBE;
     lViewOkul.DataBind();
    }

    protected void lViewOkul_ItemCommand(object sender, RadListViewCommandEventArgs e)
    {
    }

    protected void lViewOkul_ItemDataBound(object sender, Telerik.Web.UI.RadListViewItemEventArgs e)
    {
     RadComboBox cmb = (RadComboBox)e.Item.FindControl("ctlOgrenimSeviyesi");
     cmb.ItemsRequested += ctlOgrenimSeviyesi_ItemsRequested;
     cmb.SelectedIndexChanged += ctlOgrenimSeviyesi_SelectedIndexChanged;
    }

    protected void lViewOkul_ItemCreated(object sender, RadListViewItemEventArgs e)
    {
    }

    protected void ctlOgrenimSeviyesi_ItemsRequested(object o, Telerik.Web.UI.RadComboBoxItemsRequestedEventArgs e)
    {
     RadComboBox cmb = (RadComboBox)o;
     parameter = null;
     DataView dt1 = null;
     ParameterTableName = "PRMOGRENIMDURUM";
     cmb.DataSource = Parameter.GetListByFilter("ACIKLAMA LIKE '" + e.Text + "%'");
     cmb.DataTextField = "ACIKLAMA";
     cmb.DataValueField = "KAYITNO";
     cmb.DataBind();
    }

    protected void ctlOgrenimSeviyesi_SelectedIndexChanged(object o, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e)
    {
     RadComboBox cbm = (RadComboBox)lViewOkul.FindControl("cmbOkulAdi");
     PrmOgrenimDurumConstants osKod = (PrmOgrenimDurumConstants)Convert.ToDecimal(ParameterList.GetParameter(ParameterConstants.PRMOGRENIMDURUM).GetKodByKayitNo(Convert.ToDecimal(e.Value)));
     cbm.DataSource = SchoolCacheBLL.ReadAllOkul(osKod);
     cbm.DataTextField = "AD";
     cbm.DataValueField = "KAYITNO";
     cbm.DataBind();
    }
    }

  2. Alper Ozgur
    Alper Ozgur avatar
    8 posts
    Member since:
    Mar 2010

    Posted 11 May 2010 Link to this post

    I had checked in InsertItemTemplate, EditItemTemplate and ItemTemplate sections of the ListView and after selecting value from combo it looses the datasource and as usual the selectedIndex too. I had tried without LoadOnDemand feature but it doesn't works. When i get the controls out of the listview everything works as expected.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Answer
    Radoslav
    Admin
    Radoslav avatar
    1564 posts

    Posted 12 May 2010 Link to this post

    Hello Alper,

    I have reviewed the code which you post. To achieve the desired functionality you could try attaching the handler to ctlOgrenimSeviyesi.SelectedIndexChanged event into the lViewOkul.ItemCreated event instead of in lViewOkul.ItemDataBound:
    protected void lViewOkul_ItemCreated(object sender, RadListViewItemEventArgs e)
    {
        RadComboBox cmb = (RadComboBox)e.Item.FindControl("ctlOgrenimSeviyesi");
        if (cmb != null)
        {
            cmb.ItemsRequested += ctlOgrenimSeviyesi_ItemsRequested;
            cmb.SelectedIndexChanged += ctlOgrenimSeviyesi_SelectedIndexChanged;
        }
    }

    Also I suggest you to move the code for RadListView binding from Page.Load to the RadListView.NeedDataSource event:
    void lViewOkul_NeedDataSource(object sender, RadListViewNeedDataSourceEventArgs e)
    {
         RadProfile rp = new RadProfile();
         if (vwProfilData == null)
             vwProfilData = rp.ReadProfil(vwProfilData);
         lViewOkul.DataSource = vwProfilData.OgrGorduguOkulBE;
    }

    For more information please check out the following online documentation article:
    http://www.telerik.com/help/aspnet-ajax/listview-simple-vs-advanced-binding.html

    Additionally I am sending you a simple example based on your code. Please check it out and let me know if it helps you.

    Kind regards,
    Radoslav
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Back to Top