Postback fire in radcombobox i am using radajaxpanel

1 posts, 0 answers
  1. Mahesh
    Mahesh avatar
    6 posts
    Member since:
    Jan 2013

    Posted 16 Jan 2013 Link to this post

    Dear All ,
     
    my one Radcombobox  is filling according to another radcombobox  value . like on based of Account group  radcombobox i am filling account radcombobox . but my problem is that when i select any account group post back happen . i create a sample application that is working .but in my project its not working i am showing my both files .


    my aspx file is

    <%@ Page Title="" Language="C#" MasterPageFile="~/Client.Master" AutoEventWireup="true"     CodeBehind="Accounts_Grps.aspx.cs" Inherits="BurningBrightFrontEnd.Accounts.Accounts_Grps"    Theme="Skin1" %>

    <%@ MasterType VirtualPath="~/Client.Master" %>
    <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajax" %>
    <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
    <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <telerik:RadScriptBlock id="ScriptBlock1" runat="server"><br>
      <script type="text/javascript"><br>
                //global variables for the Parant Account Group ..<br>
                 var ParentAccGroupCombo;<br>
    <br>
                function pageLoad() {<br>
                    // initialize the global variables in this event all client objects  are already created and initialized <br>
                    ParentAccGroupCombo = $find("<%= trkcmbParent.ClientID %>");<br>
                }<br>
    <br>
                function LoadParentGroups(combo, eventArqs) {<br>
                    var item = eventArqs.get_item();<br>
                    ParentAccGroupCombo.set_text("Loading...");<br>
                    <br>
                    // if a continent is selected<br>
                    if (item.get_index() > 0) {<br>
                        // this will fire the ItemsRequested event of the <br>
                        // countries combobox passing the continentID as a parameter <br>
                        ParentAccGroupCombo.requestItems(item.get_value(), false);<br>
                    }<br>
                    else {<br>
                        // the -Select a continent- item was chosen<br>
                        ParentAccGroupCombo.set_text(" ");<br>
                        ParentAccGroupCombo.clearItems();<br>
                        }<br>
                }<br>
    <br>
                <br>
                function ItemsLoaded(combo, eventArqs) {<br>
                    if (combo.get_items().get_count() > 0) {<br>
                        // pre-select the first item<br>
                        combo.set_text(combo.get_items().getItem(0).get_text());<br>
                        combo.get_items().getItem(0).highlight();<br>
                    }<br>
                    combo.showDropDown();<br>
                }<br>
    <br>
            </script><br>
    </telerik:RadScriptBlock><br>

        <table cellpadding="0" cellspacing="10" width="98%" class="border" align="center">
            <tr>
                <td width="28%" valign="top" class="border">
                    <div style="overflow: scroll;">
                        <telerik:RadTreeView ID="trvList" runat="server" OnNodeClick="trvList_NodeClick"
                            SingleExpandPath="True">
                        </telerik:RadTreeView>
                    </div>
                </td>
                <td width="70%" valign="top">
                    <table cellpadding="0" cellspacing="10" width="100%" class="border">
                        <tr>
                            <td align="right" width="20%">
                                <span class="mandatory">*</span>Group Name :
                            </td>
                            <td width="80%">
                                <asp:TextBox ID="txtGroupName" SkinID="medium" runat="server" MaxLength="50"></asp:TextBox>
                            </td>
                        </tr>
                        <tr>
                            <td align="right">
                                <span class="mandatory">*</span>Short Name :
                            </td>
                            <td>
                                <asp:TextBox ID="txtShortname" SkinID="medium" runat="server" MaxLength="25"></asp:TextBox>
                            </td>
                        </tr>
                     
                     
    <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" Height="200px" Width="300px"><br>
                            <tr><br>
                                <td align="right"><br>
                                    <span class="mandatory">*</span>Primary :<br>
                                </td><br>
                                <td colspan="2"><br>
                              <br>
                                  <telerik:RadComboBox ID="trkcmbPrimary" <br>
                                      runat="server" <br>
                                      Width="205px" <br>
                                      OnSelectedIndexChanged="trkcmbPrimary_SelectedIndexChanged"<br>
                                      AutoPostBack="True" <br>
                                      onitemsrequested="trkcmbPrimary_ItemsRequested"><br>
                                   </telerik:RadComboBox><br>
                                        <br>
                                </td><br>
                         </tr><br>
                            <tr><br>
                                <td align="right"> <br>
                                <span class="mandatory">*</span>parent :<br>
                                </td><br>
                                <td colspan="2"><br>
                                </td><br>
                                <td><br>
                                    <telerik:RadComboBox ID="trkcmbParent" Width="205px" runat="server" <br>
                                       OnClientItemsRequested="ItemsLoaded"<br>
                                       onitemsrequested="trkcmbParent_ItemsRequested" ><br>
                                    </telerik:RadComboBox><br>
                              </td><br>
                              <br>
                            </tr><br>
                     </telerik:RadAjaxPanel>

                        <tr>
                            <td>
                                <asp:HiddenField ID="hfAccGrpId" runat="server" />
                            </td>
                            <td>
                                <asp:Button ID="btnReset" runat="server" BorderStyle="None" CssClass="button" Text="Reset"
                                    OnClick="btnReset_Click" />
                                <asp:Button ID="btnSave" BorderStyle="None" CssClass="button" runat="server" Text="Save"
                                    OnClick="btnSave_Click" OnClientClick="javascript:return fnValidAccountGroup();" />
                                <asp:Button ID="btnDelete" runat="server" Visible="false" Text="Button" />
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
    </asp:Content>

    my aspx.cs file is

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Data;
    using System.Data.SqlClient;
    using BurningBrightClassLibrary.clsComm_Connection;
    using BurningBrightClassLibrary.clsAccount;
    using WebTools;
    using Telerik.Web.UI;

    namespace BurningBrightFrontEnd.Accounts
    {
        #region clsFormAccountGroup
        public partial class Accounts_Grps : System.Web.UI.Page
        {

            clsUser mobjUsr = new BurningBrightClassLibrary.clsComm_Connection.clsUser();
            clsAccountGroup mobjAccountGroup = new BurningBrightClassLibrary.clsAccount.clsAccountGroup();
            modComm mobjModd = new modComm();
            clsCommon mobjComm = new clsCommon();
            clsLocation mobjlocation = new clsLocation();
            String strFrmAction = "INSERT";
            const int Level =30 ;
            Boolean blnTreeFlag;
            int ProviderID = 0;
            
            #region Events
            protected void Page_Load(object sender, EventArgs e)
            {
                clsGsystem Gsystem = (clsGsystem)Session["Gsystem"];
                if (Gsystem == null)
                {
                    return;
                }
                if (!Page.IsPostBack)
                {
                    Page.Title = Convert.ToString(modComm.stPageTitle.CommonStr) + Convert.ToString(Session["MODULENAME"]) + "Account Group Master";
                    string PAGEID = modComm.stPageID.Accounts.Master.GroupMaster;
                    Session["PAGEID"] = PAGEID;

                    if (Gsystem.ROLE_ID != (Convert.ToInt32(clsGsystem.SuperUser.Super_User)).ToString())
                        mobjModd.fnApplyRights(ref btnSave, ref btnDelete, PAGEID, Gsystem.ROLE_ID);

                    strFrmAction = Convert.ToString(ClsGlobal.enumAction.INSERT);
                    ViewState["intAccountGroup_Id"] = 0;
                    ViewState["intRecord_Modified_Count"] = 0;
                    ViewState["AccLevel"] = 0;
                    fnLoad_Tree();
                    fnGetAccPrimaryGrpDetail();

                    if (Request.QueryString != null && Request.QueryString.Count > 0)
                    {
                        ProviderID = int.Parse(Request.QueryString["id"].ToString());
                        hfAccGrpId.Value = Convert.ToString(ProviderID);
                        fnLoadAccountGroup_Master(ProviderID);
                        strFrmAction = Convert.ToString(ClsGlobal.enumAction.UPDATE);
                    }
                    ViewState["strFrmAction"] =strFrmAction ;
                    txtGroupName.Focus();

                }
            }

          


            protected void trvList_NodeClick(object sender, RadTreeNodeEventArgs e)
            {
                try
                {
                    fnLoadAccountGroup_Master(Convert.ToInt16( trvList.SelectedNode.Value));
                }
                catch (Exception ex)
                {   
                    WebExceptionHandler.HandleException(ex.ToString()) ;
                }
            }

        
    <br>
          protected void trkcmbPrimary_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)<br>
          {<br>
             LoadParentAccGroup(Convert.ToInt16(e.Value));<br>
          }<br>
     protected void trkcmbPrimary_ItemsRequested(object sender, RadComboBoxItemsRequestedEventArgs e)<br>
          {<br>
              try<br>
              {<br>
                  fnGetAccPrimaryGrpDetail();<br>
              }<br>
              catch (Exception ex)<br>
              {<br>
                  WebExceptionHandler.HandleException(ex.ToString());<br>
              }<br>
          }<br>
    <br>
          protected void trkcmbParent_ItemsRequested(object sender, RadComboBoxItemsRequestedEventArgs e)<br>
          {<br>
              try<br>
              {<br>
                  LoadParentAccGroup(Convert.ToInt16(e.Text));<br>
              }<br>
              catch (Exception ex)<br>
              {<br>
                  WebExceptionHandler.HandleException(ex.ToString());<br>
              }<br>
    <br>
          }<br>
    <br>
         <br>
          protected void LoadParentAccGroup(int PrimaryAccGroupId)<br>
          {<br>
              if (PrimaryAccGroupId <= 0)<br>
              {<br>
                  return;<br>
              }<br>
              int intPriAccGroupID = 0;<br>
              intPriAccGroupID = PrimaryAccGroupId;<br>
              if (Convert.ToString(ViewState["strFrmAction"]) == "INSERT")<br>
              {<br>
                  LoadCboParent(intPriAccGroupID, 0);<br>
              }<br>
              else<br>
              {<br>
                  if (Convert.ToString(trvList.SelectedValue) == "")<br>
                  {<br>
                      LoadCboParent(intPriAccGroupID, 0);<br>
                  }<br>
                  else<br>
                  {<br>
                      LoadCboParent(intPriAccGroupID, Convert.ToInt16(trvList.SelectedValue));<br>
                  }<br>
              }<br>
          }<br>

            #endregion

            #endregion

            #region Procedures
            
                private void LoadCboParent(int PriAccGroupId,int AcctId)
            {
                DataTable DtAccGrp ;
                try
                {
                    string  strFilter = "";
                    strFilter = "";
                    strFilter = "PRIMARYACCOUNTGROUPID = " + PriAccGroupId;
                    if ((AcctId != 0)) {
                        strFilter = strFilter +  " AND ";
                        strFilter = strFilter +  " AccountGroupId <> " + AcctId;
                    }
                    if ((Level  != 0))
                    {
                        if (Convert.ToInt16(ViewState["AccLevel"]) > 0 )
                        {
                            if (Convert.ToInt16(ViewState["AccLevel"]) == 1)
                            {
                                strFilter = strFilter + " AND ";
                                strFilter = strFilter + "AccountGroupLevel = " + Convert.ToInt16(ViewState["AccLevel"]);
                            }
                            else
                            {
                                strFilter = strFilter + " AND ";
                                strFilter = strFilter + "AccountGroupLevel < " + Convert.ToInt16(ViewState["AccLevel"]);
                            }
                            
                        }
                        else
                        {
                            strFilter = strFilter + " AND ";
                            strFilter = strFilter + "AccountGroupLevel < " + Level;
                        }
                        
                    }
                    if ((AcctId != 0)) {
                        strFilter = strFilter + " AND ";
                        strFilter = strFilter +  " ISNULL(ParentAccountGroupId,0) <> " + AcctId ;
                    }                
                    //DtAccGrp = mobjAccountGroup.fnGetParentAccountGroup(AcctId, PriAccGroupId,AcctId,Level );//old
                    DataTable DtAccGroups = (DataTable)ViewState["DtAccGroups"];
                    DataView Dv = new DataView(DtAccGroups, strFilter, "AccountGroupSortIndex", DataViewRowState.CurrentRows); ;
                    DataTable Dttemp = Dv.ToTable();
                    mobjModd.fncFillTelDropDownList_Dt(ref trkcmbParent, ref Dttemp, "AccountGroupShortName", "AccountGroupId");
                }

                catch (Exception ex)
                {
                    WebExceptionHandler.HandleException(ex.ToString());
                }
            }
         
       private void fnGetAccPrimaryGrpDetail()<br>
            {<br>
                try<br>
                {<br>
                    DataTable DtAccGroups = (DataTable)ViewState["DtAccGroups"];<br>
                    DataView Dv = new DataView(DtAccGroups,
    "AccountGroupLevel = 1", "AccountGroupSortIndex",
    DataViewRowState.CurrentRows); ;<br>
                    DataTable Dttemp =Dv.ToTable();<br>
                    mobjModd.fncFillTelDropDownList_Dt(ref trkcmbPrimary,
    ref Dttemp, "PrimaryAccountGroupShortName", "PrimaryAccountGroupId");<br>
                }<br>
                catch (Exception ex)<br>
                {<br>
                    WebExceptionHandler.HandleException(ex.ToString());<br>
                }<br>
    <br>
            }<br>



    #region Fill_Tree

            private void fnLoad_Tree()
            {
                DataTable DtAccGroups;
                try
                {
                    blnTreeFlag = true;
                    trvList.Nodes.Clear();
                    blnTreeFlag = false;
                    DtAccGroups = mobjAccountGroup.fnGet_AccountGroup_Data(0, 0, 0, 0, "");
                    ViewState["DtAccGroups"] = DtAccGroups;
                    trvList.Nodes.Clear();
                    trvList.DataTextField = "AccountGroupShortName";
                    trvList.DataValueField = "AccountGroupId";
                    trvList.DataFieldID = "AccountGroupId";
                    trvList.DataFieldParentID = "ParentAccountGroupId";
                    trvList.DataSource = DtAccGroups;
                    trvList.DataBind();
                }
                catch (Exception ex)
                {
                    WebExceptionHandler.HandleException(ex.ToString());
                }
            }

            private void fnGetAccGrpDetail()
            {
                RadTreeNode tvNode = new RadTreeNode();
                string strParent = null;
                DataView objDv = null;
                DataRowView objDrv = null;
                string strName = null;
                DataTable DtAccGroups;
                long AcctGrId = 0;
                long PriAcctGrID = 0;
                try
                {
                    blnTreeFlag = true;
                   trvList.Nodes.Clear();
                    blnTreeFlag = false;

                    DtAccGroups = mobjAccountGroup.fnGet_AccountGroup_Data(0, 0, 0, 0, "");
                    ViewState["DtAccGroups"] = DtAccGroups;
                    objDv = new DataView(DtAccGroups, "AccountGroupLevel = 1", "AccountGroupSortIndex", DataViewRowState.CurrentRows);
                    foreach (DataRowView objDrv_loopVariable in objDv)
                    {
                        objDrv = objDrv_loopVariable;
                        AcctGrId = Convert.ToInt16(objDrv["AccountGroupId"]);
                        PriAcctGrID = Convert.ToInt16(objDrv["PrimaryAccountGroupId"]);
                        if (AcctGrId == PriAcctGrID)
                        {
                            tvNode = new RadTreeNode();
                            tvNode.Text = Convert.ToString(objDrv["AccountGroupShortName"]);
                            tvNode.Value = Convert.ToString(objDrv["AccountGroupId"]);
                            //if (objDrv["AccountGroupId"] == objDrv["PrimaryAccountGroupId"]) {
                            //    tvNode.ImageIndex = 1;
                            //    tvNode.SelectedImageIndex = 1;
                            //}
                            
                            trvList.Nodes.Add(AddChilds(ref tvNode, ref DtAccGroups));
                            

                        }
                    }
                }
                catch (Exception ex)
                {
                    WebExceptionHandler.HandleException(ex.ToString());
                }
            }

            private RadTreeNode AddChilds(ref  RadTreeNode parent, ref DataTable DTAccGroup)
            {
                try
                {
                    string FilterStr = "ParentAccountGroupId= " + parent.Value + " AND " + "AccountGroupId <> " + parent.Value;
                    DataRow[] Dr = DTAccGroup.Select(FilterStr);
                    if (Dr.Length == 0)
                    {
                        return parent;
                    }
                    RadTreeNode ChildNode = new RadTreeNode();
                    for (int intctr = 0; intctr < Dr.Length; intctr++)
                    {
                        ChildNode = new RadTreeNode();
                        if (Dr[intctr]["AcctGroupEditStatus"] == "Y")
                        {
                            //ChildNode.imageindex = 0;
                            //ChildNode.SelectedImageIndex = 0;
                        }
                        else
                        {
                            if (Convert.ToInt16(Dr[intctr]["AccountGroupLevel"]) != 1 & Dr[intctr]["AcctGroupEditStatus"] == "N")
                            {
                                //ChildNode.imageindex = 2;
                                //ChildNode.SelectedImageIndex = 2;
                            }
                        }
                        ChildNode.Text = Convert.ToString(Dr[intctr]["AccountGroupShortName"]);
                        ChildNode.Value = Convert.ToString(Dr[intctr]["AccountGroupId"]);
                        parent.Nodes.Add(AddChilds(ref ChildNode ,ref DTAccGroup));

                    }
                    return parent;
                }

                catch (Exception ex)
                {
                    throw ex;
                }

            }

            private void test()
            {
                RadTreeNode root1 = new RadTreeNode("root1");
                trvList.Nodes.Add(root1);

                RadTreeNode root2 = new RadTreeNode("root2");
                root2.Nodes.Add(new RadTreeNode("child1"));
                root2.Nodes.Add(new RadTreeNode("child2"));
                root2.Nodes.Add(new RadTreeNode("child3"));
                trvList.Nodes.Add(root2);
                RadTreeNode root3 = new RadTreeNode("root3");
                RadTreeNode child3 = new RadTreeNode("child3");
                child3.Nodes.Add(new RadTreeNode("child node under child3"));
                root3.Nodes.Add(child3);
                trvList.Nodes.Add(root3);
            }

            #endregion


        }

            

    }




            #endregion

    #endregion





Back to Top