示例#1
0
        protected void cgOrders_PreRender(object sender, EventArgs e)
        {
            if (cgOrders.TopPagerRow != null)
            {
                cgOrders.TopPagerRow.Visible = true;
                ((TextBox)cgOrders.HeaderRow.FindControl("txtFilterId")).Text         = GetStringState("OrderId");
                ((TextBox)cgOrders.HeaderRow.FindControl("txtFromDate")).Text         = GetStringState(FROM_ORDER_PLACED_DATE_FILTER);
                ((TextBox)cgOrders.HeaderRow.FindControl("txtToDate")).Text           = GetStringState(TO_ORDER_PLACED_DATE_FILTER);
                ((TextBox)cgOrders.HeaderRow.FindControl("txtFromActivityDate")).Text = GetStringState(FROM_LAST_ACTIVITY_DATE_FILTER);
                ((TextBox)cgOrders.HeaderRow.FindControl("txtToActivityDate")).Text   = GetStringState(TO_LAST_ACTIVITY_DATE_FILTER);
                ((TextBox)cgOrders.HeaderRow.FindControl("txtEmail")).Text            = GetStringState(EMAIL_FILTER);

                DropDownList ddlCountries = (DropDownList)cgOrders.HeaderRow.FindControl("ddlCountries");
                if (GetStringState(SHIPPING_COUNTRY_ID_FILTER) != string.Empty)
                {
                    ddlCountries.Items.FindByValue(GetStringState(SHIPPING_COUNTRY_ID_FILTER)).Selected = true;
                }

                DropDownList ddlStatus = (DropDownList)cgOrders.HeaderRow.FindControl("ddlStatus");
                if (GetStringState(ORDER_STATUS_FILTER) != string.Empty)
                {
                    ddlStatus.Items.FindByValue(GetStringState(ORDER_STATUS_FILTER)).Selected = true;
                }

                DropDownList ddlIssue = (DropDownList)cgOrders.HeaderRow.FindControl("ddlIssue");
                if (GetStringState(ISSUE_FILTER) != string.Empty)
                {
                    ddlIssue.Items.FindByValue(GetStringState(ISSUE_FILTER)).Selected = true;
                }

                DropDownList ddlDelivery = (DropDownList)cgOrders.HeaderRow.FindControl("ddlDelivery");
                if (GetStringState(SHIPPING_NAME_FILTER) != string.Empty)
                {
                    ddlDelivery.Items.FindByValue(GetStringState(SHIPPING_NAME_FILTER)).Selected = true;
                }
            }

            var orders = cgOrders.DataSource as OrderOverviewModel[];

            if (orders != null)
            {
                for (int i = 0; i < cgOrders.Rows.Count; i++)
                {
                    CheckBox cb = cgOrders.Rows[i].FindControl("cbChosen") as CheckBox;

                    if (ChosenOrders.Contains(orders[i].Id))
                    {
                        cb.Checked = true;
                    }

                    SetChosenOrders(orders[i].Id, cb.Checked);
                }
            }
        }
示例#2
0
 private void SetChosenOrders(int orderId, bool chosen)
 {
     if (orderId != 0)
     {
         if ((chosen) && !ChosenOrders.Contains(orderId))
         {
             ChosenOrders.Add(orderId);
             NotChosenOrders.Remove(orderId);
         }
         else if ((!chosen) && (ChosenOrders.Contains(orderId)))
         {
             ChosenOrders.Remove(orderId);
             NotChosenOrders.Add(orderId);
         }
     }
 }
        protected void gvOrders_PreRender(object sender, EventArgs e)
        {
            if (gvOrders.TopPagerRow != null)
            {
                gvOrders.TopPagerRow.Visible = true;
                ((TextBox)gvOrders.HeaderRow.FindControl("txtFilterId")).Text = GetStringState(ORDER_ID_FILTER);
                ((TextBox)gvOrders.HeaderRow.FindControl("txtFromDate")).Text = GetStringState(FROM_ORDER_PLACED_DATE_FILTER);
                ((TextBox)gvOrders.HeaderRow.FindControl("txtToDate")).Text   = GetStringState(TO_ORDER_PLACED_DATE_FILTER);

                DropDownList ddlDelivery = (DropDownList)gvOrders.HeaderRow.FindControl("ddlDelivery");
                if (GetStringState(SHIPPING_NAME_FILTER) != string.Empty)
                {
                    ddlDelivery.Items.FindByValue(GetStringState(SHIPPING_NAME_FILTER)).Selected = true;
                }

                DropDownList ddlCountries = (DropDownList)gvOrders.HeaderRow.FindControl("ddlCountries");
                if (GetStringState(SHIPPING_COUNTRY_ID_FILTER) != string.Empty)
                {
                    ddlCountries.Items.FindByValue(GetStringState(SHIPPING_COUNTRY_ID_FILTER)).Selected = true;
                }
            }

            var orders = gvOrders.DataSource as OrderOverviewModel[];

            for (int i = 0; i < gvOrders.Rows.Count; i++)
            {
                CheckBox cb = gvOrders.Rows[i].FindControl("cbChosen") as CheckBox;

                if (ChosenOrders.Contains(orders[i].Id))
                {
                    cb.Checked = true;
                }

                SetChosenOrders(orders[i].Id, cb.Checked);
            }
        }