خرید بک لینک

Vote count: 0

Hello everybody and thanks in advance,

I've made a class in my .cs file and then declared a list<> of it like this...

    public partial class MyClass : System.Web.UI.Page
    {
        public List<PrecioStock> PreciosYStocks = new List<PrecioStock>();


        protected void Page_Load(object sender, EventArgs e)
        {
...
...

    public class PrecioStock
    {
        public string Precio;
        public string Stock;

        public PrecioStock(string Precio, string Stock)
        {
            this.Precio = Precio;
            this.Stock = Stock;
        }

        public void SetPrecio(string nuevoPrecio)
        {
            this.Precio = nuevoPrecio;
        }

        public void SetStock(string nuevoStock)
        {
            this.Stock = nuevoStock;
        }

        public string GetPrecio()
        {
            retu this.Precio;
        }

        public string GetStock()
        {
            retu this.Stock;
        }

    }

Then, I fill it this way, with some textboxes' texts...

            PreciosYStocks.Clear();

            foreach (ListItem items in ControlListaGenerico.Items)
            {
                if (items.Selected)
                {
                    for (int i = 0; i < TablaDeDatos.Rows.Count; i++)
                    {
                        if(items.Value.Equals(TablaDeDatos.Rows[i]["ID_FORMATO"].ToString()))
                        {
                            TextBox Precio = (TextBox)Precio_Stock_PN.FindControl("NuevoPrecioTB_" + items.Value);
                            Precio.Text = TablaDeDatos.Rows[i]["PRECIO"].ToString();

                            TextBox Stock = (TextBox)Precio_Stock_PN.FindControl("NuevoStockTB_" + items.Value);
                            Stock.Text = TablaDeDatos.Rows[i]["STOCK"].ToString();

                            PreciosYStocks.Add(new PrecioStock(Precio.Text, Stock.Text));

                            break;
                        }
                    }
                }
            }

Well, it seems to fill well, but the problem is that when I click the UPDATE button of the DetailsView, this generates a postback event, the data is lost and I'm not be able to access to it anymore.

So, how can I access to it after postback? I mean, make it persistent.

I've read about "viewState" and "Session" ways but don't know how to implement them, in case they are the answer to this.

Please, help and thanks again.

asked 1 min ago

برچسب: نویسنده: استخدام کار تاريخ: شنبه 21 فروردين 1395 ساعت: 21:40

صفحه بندی