コード例 #1
0
        protected void RadListViewBaseItems_ItemDataBound(object sender, RadListViewItemEventArgs e)
        {
            try
            {
                if (e.Item is RadListViewEditableItem && e.Item.IsInEditMode)
                {
                    RadListViewEditableItem item = e.Item as RadListViewEditableItem;
                    DropDownList            list = item.FindControl("ddlCategory") as DropDownList;
                    var categorylist             = _menuManagement.GetAllMenuItemCategory();
                    list.Items.Clear();
                    list.Items.Add(new ListItem("--Please select--", "0"));
                    foreach (var cate in categorylist)
                    {
                        list.Items.Add(new ListItem(cate.CategoryName, Convert.ToString(cate.ID)));
                    }
                    Label strcatid = e.Item.FindControl("lblBoxCategoryId") as Label;
                    list.SelectedValue = strcatid.Text;
                }
                if (e.Item is RadListViewDataItem)
                {
                    var   dataItem = ((RadListViewDataItem)e.Item).DataItem;
                    Label lblId    = e.Item.FindControl("lblBaseitemId") as Label;

                    RadButton editLink = (RadButton)e.Item.FindControl("btnEditBaseItem");
                    editLink.Attributes["href"]    = "javascript:void(0);";
                    editLink.Attributes["onclick"] = String.Format("return ShowEditForm('{0}');", lblId.Text);
                }
            }
            catch (Exception ex)
            {
                //write to Elma
                ErrorSignal.FromCurrentContext().Raise(ex);
            }
        }
コード例 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(Convert.ToString(Session["USERID"])))
            {
                Response.Redirect("~/Account/Login.aspx");
            }

            if (!IsPostBack)
            {
                try
                {//bind dropdown
                    ddlCategory.Items.Clear();
                    ddlCategory.Items.Add(new ListItem("--Please select--", "0"));
                    var categorylist = _menuManagement.GetAllMenuItemCategory();
                    foreach (var cate in categorylist)
                    {
                        ddlCategory.Items.Add(new ListItem(cate.CategoryName, Convert.ToString(cate.ID)));
                    }

                    int BASEITEMID = 0;

                    string baseitemId = Request.QueryString["ID"];

                    Int32.TryParse(baseitemId, out BASEITEMID);
                    if (BASEITEMID > 0)
                    {
                        btnUpdateBaseItem.Visible  = true;
                        lblBaseItemActionType.Text = "Update Base Item";

                        var baseitemData = _baseItemManagement.GetBaseItem(BASEITEMID);
                        if (baseitemData != null)
                        {
                            txtItemTitle.Text         = baseitemData.BaseItemTitle;
                            ddlCategory.SelectedIndex = Convert.ToUInt16(baseitemData.CategoryId);
                            txtBaseItemCode.Text      = baseitemData.BaseItemCode;
                            txtTitleDesc.Text         = baseitemData.BaseItemTitleDescription;
                            txtDesc.Text       = baseitemData.BaseItemDescription;
                            txtSubDesc.Text    = baseitemData.BaseItemSubDescription;
                            txtAttributes.Text = baseitemData.BaseItemAttributes;

                            txtCategoryCode.Text = _menuManagement.GetMenuItemCategoryCode(Convert.ToUInt16(baseitemData.CategoryId));
                        }
                    }
                    else if (BASEITEMID == 0)
                    {
                        btnAddBaseItem.Visible     = true;
                        lblBaseItemActionType.Text = "Add Base Item";
                    }
                    else
                    {
                        btnAddBaseItem.Visible     = false;
                        btnUpdateBaseItem.Visible  = false;
                        lblBaseItemActionType.Text = "";
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "mykey", "CancelEdit();", true);
                    }
                }
                catch (Exception ex)
                {
                    //write to Elma
                    ErrorSignal.FromCurrentContext().Raise(ex);
                }
            }
        }