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; } } } } }
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; } } } } }