/// <summary>
 /// Loads the descriptors.
 /// </summary>
 private void LoadDescriptors()
 {
     Query query = new Query(Descriptor.Schema).
     WHERE(Descriptor.Columns.ProductId, Comparison.Equals, productId).
     ORDER_BY(Descriptor.Columns.SortOrder);
       DescriptorCollection descriptorCollection = new DescriptorController().FetchByQuery(query);
       if(descriptorCollection.Count > 0) {
     base.MasterPage.MessageCenter.ResetPanelsVisibility();
     pnlGrid.Visible = true;
     dgDescriptors.DataSource = descriptorCollection;
     dgDescriptors.ItemDataBound += new DataGridItemEventHandler(dgDescriptors_ItemDataBound);
     dgDescriptors.Columns[0].HeaderText = LocalizationUtility.GetText("hdrEdit");
     dgDescriptors.Columns[1].HeaderText = LocalizationUtility.GetText("hdrMove");
     dgDescriptors.Columns[2].HeaderText = LocalizationUtility.GetText("hdrTitle");
     dgDescriptors.Columns[3].HeaderText = LocalizationUtility.GetText("hdrSortOrder");
     dgDescriptors.Columns[4].HeaderText = LocalizationUtility.GetText("hdrDescriptor");
     dgDescriptors.Columns[5].HeaderText = LocalizationUtility.GetText("hdrDelete");
     dgDescriptors.DataBind();
     ImageButton lbUp = dgDescriptors.Items[0].Cells[1].FindControl("lbUp") as ImageButton;
     if(lbUp != null) {
       lbUp.Visible = false;
     }
     ImageButton lbDown = dgDescriptors.Items[dgDescriptors.Items.Count - 1].Cells[1].FindControl("lbDown") as ImageButton;
     if(lbDown != null) {
       lbDown.Visible = false;
     }
       }
       else {
     pnlGrid.Visible = false;
     base.MasterPage.MessageCenter.DisplayInformationMessage(LocalizationUtility.GetText("lblNoDescriptors"));
       }
 }
 /// <summary>
 /// Handles the ItemReorder event of the Items control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
 protected void Items_ItemReorder(object sender, EventArgs e)
 {
     try {
     ImageButton theButton = sender as ImageButton;
     Query query = new Query(Descriptor.Schema).
       WHERE(Descriptor.Columns.ProductId, Comparison.Equals, productId).
       ORDER_BY(Descriptor.Columns.SortOrder);
     DescriptorCollection descriptorCollection = new DescriptorController().FetchByQuery(query);
     if(descriptorCollection != null) {
       int descriptorId = 0;
       int.TryParse(theButton.CommandArgument.ToString(), out descriptorId);
       if(descriptorId > 0) {
     Descriptor descriptorMoved = descriptorCollection.Find(delegate(Descriptor descriptor) {
       return descriptor.DescriptorId == descriptorId;
     });
     int index = descriptorCollection.IndexOf(descriptorMoved);
     descriptorCollection.RemoveAt(index);
     if(theButton.CommandName.ToLower() == "up") {
       descriptorCollection.Insert(index - 1, descriptorMoved);
     }
     else if(theButton.CommandName.ToLower() == "down") {
       descriptorCollection.Insert(index + 1, descriptorMoved);
     }
     int i = 1;
     foreach(Descriptor descriptor in descriptorCollection) {
       descriptor.SortOrder = i++;
     }
     descriptorCollection.SaveAll(WebUtility.GetUserName());
     LoadDescriptors();
       }
     }
       }
       catch(Exception ex) {
     Logger.Error(typeof(descriptors).Name + ".Items_ItemReorder", ex);
     base.MasterPage.MessageCenter.DisplayCriticalMessage(ex.Message);
       }
 }