예제 #1
0
        private void LoadData()
        {
            Guid      subId     = SessionHelper.GetSession(SessionKey.SubDomain) == string.Empty ? Guid.Empty : new Guid(SessionHelper.GetSession(SessionKey.SubDomain));
            SubDomain subDomain = new SubDomain {
                Id = subId
            };

            CMS.MenuMasterCollection listMenuMaster = subId == Guid.Empty ? CMS.MenuMasterCollection.GetMenuMasterCollection() : subDomain.GetMenuMastersBelongTo();
            ddlListMenuMaster.DataSource     = listMenuMaster;
            ddlListMenuMaster.DataTextField  = "Name";
            ddlListMenuMaster.DataValueField = "Id";
            ddlListMenuMaster.DataBind();

            using (SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["PSCPortalConnectionString"].ConnectionString))
            {
                SqlCommand com = new SqlCommand();
                com.Connection = con;
                con.Open();
                com.Parameters.AddWithValue("@DataId", DataId);
                com.CommandText = "Select MenuMasterId from PortletMenu where DataId=@DataId";

                Object menuMaster = com.ExecuteScalar();
                if (menuMaster != null)
                {
                    Guid menuMasterId = (Guid)menuMaster;
                    for (int i = 0; i < listMenuMaster.Count; i++)
                    {
                        if (listMenuMaster[i].Id == menuMasterId)
                        {
                            ddlListMenuMaster.SelectedIndex = i;
                            break;
                        }
                    }
                }
            }
        }
예제 #2
0
        private void LoadData()
        {
            CMS.MenuMasterCollection listMenuMaster = CMS.MenuMasterCollection.GetMenuMasterCollection();
            ddlListMenuMaster.DataSource     = listMenuMaster;
            ddlListMenuMaster.DataTextField  = "Name";
            ddlListMenuMaster.DataValueField = "Id";
            ddlListMenuMaster.DataBind();

            using (
                SqlConnection con =
                    new SqlConnection(
                        System.Configuration.ConfigurationManager.ConnectionStrings["PSCPortalConnectionString"]
                        .ConnectionString))
            {
                SqlCommand com = new SqlCommand {
                    Connection = con
                };
                con.Open();
                com.Parameters.AddWithValue("@DataId", DataId);
                com.CommandText = "Select MenuMasterId from PortletMenu where DataId=@DataId";

                Object menuMaster = com.ExecuteScalar();
                if (menuMaster != null)
                {
                    Guid menuMasterId = (Guid)menuMaster;
                    for (int i = 0; i < listMenuMaster.Count; i++)
                    {
                        if (listMenuMaster[i].Id == menuMasterId)
                        {
                            ddlListMenuMaster.SelectedIndex = i;
                            break;
                        }
                    }
                }
            }
        }