Esempio n. 1
0
        /// <summary>
        /// Handles the ItemCommand event of the grdResolutions control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Web.UI.WebControls.DataGridCommandEventArgs"/> instance containing the event data.</param>
        protected void grdResolutions_ItemCommand(object sender, DataGridCommandEventArgs e)
        {
            Resolution m;
            var        itemIndex = e.Item.ItemIndex;

            switch (e.CommandName)
            {
            case "up":
                //move row up
                if (itemIndex == 0)
                {
                    return;
                }
                m            = ResolutionManager.GetById(Convert.ToInt32(e.CommandArgument));
                m.SortOrder -= 1;
                ResolutionManager.SaveOrUpdate(m);
                break;

            case "down":
                //move row down
                if (itemIndex == grdResolutions.Items.Count - 1)
                {
                    return;
                }
                m            = ResolutionManager.GetById(Convert.ToInt32(e.CommandArgument));
                m.SortOrder += 1;
                ResolutionManager.SaveOrUpdate(m);
                break;
            }
            BindResolutions();
        }
Esempio n. 2
0
        /// <summary>
        /// Handles the Update event of the grdResolutions control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Web.UI.WebControls.DataGridCommandEventArgs"/> instance containing the event data.</param>
        protected void grdResolutions_Update(object sender, DataGridCommandEventArgs e)
        {
            var txtResolutionName = (TextBox)e.Item.FindControl("txtResolutionName");
            var pickimg           = (PickImage)e.Item.FindControl("lstEditImages");

            if (txtResolutionName.Text.Trim() == "")
            {
                throw new ArgumentNullException("Resolution name is empty.");
            }

            var m = ResolutionManager.GetById(Convert.ToInt32(grdResolutions.DataKeys[e.Item.ItemIndex]));

            m.Name     = txtResolutionName.Text.Trim();
            m.ImageUrl = pickimg.SelectedValue;
            ResolutionManager.SaveOrUpdate(m);

            grdResolutions.EditItemIndex = -1;
            BindResolutions();
        }