2

I'm trying to load and bind records with ListView but i'm facing these two issues

  1. It is taking long time to load the records
  2. When i save records after update, it gives error Maximum request length exceeded.

Below is the first method which calls on button click.

private void LoadItems()
        {
            string warehouseCode = txtWarehouseCode.Text;

            if (string.IsNullOrEmpty(warehouseCode))
            {
                ShowMessage(GetLocalResourceObject("1208").ToString(), Messages.Red);
                return;
            }
            DataTable dt = invManager.ItemCardStockManager.SelectOpeningStock(warehouseCode);
            lsvItems.DataSource = dt;
            lsvItems.DataBind();
        }

And here is the ItemDataBound method which calls during binding.

protected void lsvItem_ItemDataBound(object sender, ListViewItemEventArgs e)
        {
            if (e.Item.ItemType == ListViewItemType.DataItem)
            {
                HiddenField hdnHigherUnitQty = e.Item.FindControl("hdnHigherUnitQty") as HiddenField;
                HiddenField hdnBaseUnitQty = e.Item.FindControl("hdnBaseUnitQty") as HiddenField;
                HiddenField hdnOpeningCostPrice = e.Item.FindControl("hdnOpeningCostPrice") as HiddenField;
                HiddenField hdnUnitFraction = e.Item.FindControl("hdnUnitFraction") as HiddenField;
                HiddenField hdnHigherUnitType = e.Item.FindControl("hdnHigherUnitType") as HiddenField;

                decimal uq1 = (hdnHigherUnitQty.Value == "" ? decimal.Parse("0") : decimal.Parse(hdnHigherUnitQty.Value));
                decimal uq2 = (hdnBaseUnitQty.Value == "" ? decimal.Parse("0") : decimal.Parse(hdnBaseUnitQty.Value));
                decimal cst = (hdnOpeningCostPrice.Value == "" ? decimal.Parse("0") : decimal.Parse(hdnOpeningCostPrice.Value));
                decimal fr2 = (hdnUnitFraction.Value == "" ? decimal.Parse("0") : decimal.Parse(hdnUnitFraction.Value));
                int ut2 = (hdnHigherUnitType.Value == "" ? int.Parse("0") : int.Parse(hdnHigherUnitType.Value));

                TextBox lbHigherUnitQty = e.Item.FindControl("lbHigherUnitQty") as TextBox;
                TextBox lbBaseUnitQty = e.Item.FindControl("lbBaseUnitQty") as TextBox;
                TextBox lbOpeningCostPrice = e.Item.FindControl("lbOpeningCostPrice") as TextBox;
                TextBox lbUnitFraction = e.Item.FindControl("lbUnitFraction") as TextBox;
                TextBox lbHigherUnitType = e.Item.FindControl("lbHigherUnitType") as TextBox;

                lbHigherUnitQty.Text = uq1.ToString();
                lbBaseUnitQty.Text = uq2.ToString();
                lbOpeningCostPrice.Text = cst.ToString();
                lbUnitFraction.Text = fr2.ToString();
                lbHigherUnitType.Text = ut2.ToString();

            }
        }
Adnan Amjad
  • 2,553
  • 1
  • 20
  • 29
Muhammad Bilal
  • 125
  • 1
  • 9

0 Answers0