locked
Page Load problem RRS feed

  • Question

  • User414653628 posted

    Hi There,

    My question is: When I attempt to try a page redirection,it's logging two times to page_load of new page.

     

    protected void Page_Load(object sender, EventArgs e)
    
    {
    
    dtDenetciler.Columns.Add(denetciAdSoyad);
    dtDenetciler.Columns.Add(denetciID);
    
    dtDenetciler.Columns.Add(denetciEkipUnvan);
    
    dtDenetciler.Columns.Add(deneciEkipUnvanID);
    
    dtDenetciler.Columns.Add(denetimBaslangic);
    
    dtDenetciler.Columns.Add(denetimBitis);
    
    dropDownListDoldur();
    
    int basvuruDetayID = Convert.ToInt32(Request.QueryString["id"]);
    
    if (!IsPostBack)
    
    {
    
    DataTable dtstandart = StandartJobs.LoadStandartbyBasvuruDetay(basvuruDetayID);
    
    gvStandartSec.DataSource = dtstandart;
    
    gvStandartSec.DataBind();
    
    DropDownList drdList;
    
    foreach (GridViewRow grdRow in gvStandartSec.Rows)
    
    {
    
    drdList = (DropDownList)(gvStandartSec.Rows[grdRow.RowIndex].Cells[1].FindControl("ddlDenetimTuru"));
    
    drdList.DataSource = ParametreJobs.ParametreDoldurByParametreTip("DENETIMTIP");
    
    drdList.DataValueField = "ID";
    
    drdList.DataTextField = "PARAMETREADI";
    
    drdList.DataBind();
    
    }
    
    foreach (GridViewRow grdRow in gvStandartSec.Rows)
    
    {
    
    for (int i = 0; i < dtstandart.Rows.Count; i++)
    
    {
    
    ((DropDownList)grdRow.FindControl("ddlDenetimTuru")).SelectedValue = dtstandart.Rows["DENETIMTURID"].ToString();
    
    }
    
    }
    
    DataTable dtDenetim = DenetimJobs.LoadDenetimByBasvuruDetay(basvuruDetayID);
    
     
    
    for (int i = 0; i < dtDenetim.Rows.Count; i++)
    
    {
    
    txtDenetimBaslangicTarihiDuz.Text = dtDenetim.Rows["DENETIMBASLANGICTARIHI"].ToString();
    
    txtDenetimSureDuz.Text = dtDenetim.Rows["DENETIMSURE"].ToString();
    
    }
    
    BasvuruDetay bDenetimID = new BasvuruDetay(basvuruDetayID);
    
     
    
    DataTable dtDenetimEkibi = DenetimEkipJobs.LoadDenetimEkibiByDenetimID(bDenetimID.DENETIMID.ID);
    
    for (int i = 0; i < dtDenetimEkibi.Rows.Count; i++)
    
    {
    
    gvDenetimEkibi.DataSource = dtDenetimEkibi;
    
    gvDenetimEkibi.DataBind();
    
    }
    
    this.ViewState.Add("denetimEkipGrid", dtDenetimEkibi);
    
    ViewStateDenetciDoldur();
    
     
    
    }
    
    }



    Cheers,

    Friday, August 26, 2011 9:39 AM

Answers

  • User3866881 posted

    When I attempt to try a page redirection,it's logging two times to page_load of new page.

    You mean that when you press F5 or use something like "Response.Redirection("xxx.aspx"), the page_Load event will be get fired twice?

    If yes, I think you can try this:

    protected void Page_Load(object sender, EventArgs e)
    {
     if(Session["db"]==null)
     {
     dtDenetciler.Columns.Add(denetciAdSoyad);
     dtDenetciler.Columns.Add(denetciID);
     dtDenetciler.Columns.Add(denetciEkipUnvan);
     dtDenetciler.Columns.Add(deneciEkipUnvanID);
    dtDenetciler.Columns.Add(denetimBaslangic);
    dtDenetciler.Columns.Add(denetimBitis);
     Session["dt"]=true;   //Here Session is used as a tag flag to tell whether the page has been initialized or not.
     dropDownListDoldur();
     }

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, August 28, 2011 10:34 PM

All replies