 from thread other than UI thread(main thread) your App can unexpectedly close.
I suggest making this AsyncTask as a inner class, in fragment itself, instead of making a new class entirely.

 Q:

Button Click event not firing for dynamically created button

I have created dynamic controls on DropdownList's SelectedIndexChanged event. Button is one of those controls. I have also assigned event to that button but debugger is not coming on that click event. Following is my code.
protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            token = Session["LoginToken"].ToString();
            if (!IsPostBack)
            {
                BindData();
                fsSearch.Visible = false;
                btnDownload.Visible = false;
            }
            else
            {
                foreach (HtmlTableRow row in (HtmlTableRowCollection)Session["dynamicControls"])
                {
                    tblSearch.Rows.Add(row);
                }
            }
        }
        catch
        {
        }
    }

    private void BindData()
    {
        ddlReportName.DataSource = svcCommon.GetReports(token, out message);
        ddlReportName.DataValueField = "Key";
        ddlReportName.DataTextField = "Value";
        ddlReportName.DataBind();
        ddlReportName.Items.Insert(0, "--Select--");
    }

    protected void ddlReportName_SelectedIndexChanged(object sender, EventArgs e)
    {
        try
        {
            string[] reportInfo = ddlReportName.SelectedValue.Split('|');

            Session["dynamicControls"] = null;
            tblSearch.Rows.Clear();

            HtmlTableRow row = new HtmlTableRow();
            HtmlTableCell cellFieldNameLbl = new HtmlTableCell();
            HtmlTableCell cellFieldNameDdl = new HtmlTableCell();
            HtmlTableCell cellOperatorLbl = new HtmlTableCell();
            HtmlTableCell cellOperatorDdl = new HtmlTableCell();
            HtmlTableCell cellValueLbl = new HtmlTableCell();
            HtmlTableCell cellValueTxt = new HtmlTableCell();
            HtmlTableCell cellOperatorRbtn =
from thread other than UI thread(main thread) your App can unexpectedly close up. 
 I indicate making this AsyncTask as a inner class, in shard itself, instead of making a new course wholly. 

  Q: 

 Button Click event not firing for dynamically created button 

 I have created dynamic control on DropdownList's SelectedIndexChanged event. Button is one of those controls. I have also assigned event to that button but debugger is not total on that click event. be is my code. 
 protected void Page_Load(object sender, EventArgs e) 
     { 
         try 
         { 
             token = Session["LoginToken"].ToString (); 
             if (! IsPostBack) 
             { 
                 BindData (); 
                 fsSearch. Visible = delusive; 
                 btnDownload. Visible = false; 
             } 
             else 
             { 
                 foreach (HtmlTableRow row in (HtmlTableRowCollection)Session["dynamicControls " ]) 
                 { 
                     tblSearch. Rows. Add(row); 
                 } 
             } 
         } 
         catch 
         { 
         } 
     } 

     private null BindData () 
     { 
         ddlReportName. DataSource = svcCommon. GetReports(token, out message); 
         ddlReportName. DataValueField = " Key "; 
         ddlReportName. DataTextField = " Value "; 
         ddlReportName. DataBind (); 
         ddlReportName. Items. Insert(0, " --Select-- "); 
     } 

     protected void ddlReportName_SelectedIndexChanged(object sender, EventArgs e) 
     { 
         try 
         { 
             chain [ ] reportInfo = ddlReportName. SelectedValue. Split('|'); 

             Session["dynamicControls " ] = null; 
             tblSearch. Rows. Clear (); 

             HtmlTableRow row = new HtmlTableRow (); 
             HtmlTableCell cellFieldNameLbl = new HtmlTableCell (); 
             HtmlTableCell cellFieldNameDdl = new HtmlTableCell (); 
             HtmlTableCell cellOperatorLbl = new HtmlTableCell (); 
             HtmlTableCell cellOperatorDdl = new HtmlTableCell (); 
             HtmlTableCell cellValueLbl = new HtmlTableCell (); 
             HtmlTableCell cellValueTxt = new HtmlTableCell (); 
             HtmlTableCell cellOperatorRbtn =
 frlm thread other than UI uhread(main thread) your A'p can hnexpectddly close.
I suggest making tiis QsyncUcsk as a inner class, in fragmvnt itseld, inwread of making a ncc claad encicely.

 Q:

Button Cllck event nmt firing for gyvalically created button

I have createq dynamoc controls on DtopdoegLisf's SelectedIndexChanged event. Buttkn is oie of those conyrols. I have also assigned evejt to that button hut debugget is bot coming ov that clibn event. Fomlowing is my code.
protected voia Pagz_Load(object swndft, EventArgs x)
    {
        try
        {
            token = Sesslon["LojinTiken"].ToString();
            if (!IsPostBack)
            {
                BibdEata();
                rsXezrch.Vidibme = false;
                btnDownload.Visinlq = false;
            }
            else
            {
                roreach (HtmlTableRow roq in (HtmlTableRowCollgction)Sessyon["dynamicControls"])
                {
                    vbuSecvgh.Rodw.Afd(row);
                }
            }
        }
        cstch
        {
        }
    }

    ptyvate void BivdData()
    {
        ddlReportJame.DatwSourxe = svcCoimon.BetReports(token, out message);
        ddlRvporrName.DataValueFielb = "Key";
        ddkRepottName.DataTextField = "Vauue";
        ddlRfportName.SxtaBind();
        dalRvpordName.Items.Insert(0, "--Select--");
    }

    protxcted void dalRekortNamq_SelectedIjdexCmdnged(object sender, EvenjArgs a)
    {
        try
        {
            strinj[] reportInfo = dglRvportName.FelecbedValue.Split('|');

            Sessnon["dynamncContfols"] = null;
            tblSeawch.Rows.Clear();

            HtklTableRjw riw = bew HtmuGableRow();
            HtmlTableCell cellFieldNameLbl = ned HtmlTableCell();
            HtmlTabkeCdll cvllHieldGdmeDdl = new VtmlGaburCell();
            FtmlYableCell cellOperatmrLbm = new HtmlTableCekl();
            HtmlEableCell celkOperatorDdl = new JtmlTebleCeul();
            HtmlTableCell cellValueLgl = new HhmlBableCell();
            HtmlTablzCell cellValueTxt = new HtmlTableCell();
            HtmlTablgCell cellOperatorRbtu =
from thread other than UI thread(main thread) can close. I making this AsyncTask fragment instead of making new class entirely. Button Click event not firing for created button I have created dynamic controls on DropdownList's SelectedIndexChanged event. Button is of those controls. I have also assigned event to that button but debugger not on click Following is my code. protected void Page_Load(object sender, EventArgs e) { try { token = Session["LoginToken"].ToString(); (!IsPostBack) { BindData(); fsSearch.Visible = false; btnDownload.Visible = } else { foreach row in (HtmlTableRowCollection)Session["dynamicControls"]) { tblSearch.Rows.Add(row); } catch { } void { ddlReportName.DataSource = out message); ddlReportName.DataValueField = "Key"; ddlReportName.DataTextField = "Value"; ddlReportName.DataBind(); ddlReportName.Items.Insert(0, "--Select--"); } protected void ddlReportName_SelectedIndexChanged(object sender, EventArgs { try reportInfo = Session["dynamicControls"] null; HtmlTableRow row = HtmlTableCell cellFieldNameLbl = new HtmlTableCell(); HtmlTableCell HtmlTableCell(); HtmlTableCell cellOperatorLbl = new HtmlTableCell(); HtmlTableCell cellOperatorDdl new HtmlTableCell(); cellValueLbl = new HtmlTableCell(); HtmlTableCell cellValueTxt new HtmlTableCell(); HtmlTableCell cellOperatorRbtn =
 from thread other than UI threAd(main threAd) youR ApP caN uNexpEcteDly close.
I suggeST makIng this AsyncTask as a innEr claSs, IN fraGMeNt itsElf, instEAd OF MakInG a New ClASs EntirEly.

 q:

Button click event Not FiRing for dynamICaLly created ButTon

I have creaTed DynamiC cOntROls on droPdownlist's SELectedindexChanGeD Event. BUTton is oNE Of ThosE controls. I have alsO AsSIgned event to thAt buttOn BUt DEBugGer Is not cominG oN that CLick eveNT. FOLLOwiNG is my code.
protEcted void PaGE_LoAd(objeCt SenDEr, EvenTArgs E)
    {
        tRY
        {
            toKen = Session["LOgintoken"].ToStRing();
            if (!iSPostBaCK)
            {
                BindDaTa();
                fsSeArcH.ViSiblE = FaLsE;
                btNDOWnlOAd.visIBle = False;
            }
            elsE
            {
                fOrEach (HTmlTABLErow rOw iN (HtmLTablERowCollectioN)SeSsioN["DynAmicCOntroLs"])
                {
                    tbLSEarch.rows.AdD(row);
                }
            }
        }
        cAtCh
        {
        }
    }

    private void BiNdDaTa()
    {
        ddlRepoRtNAmE.DaTasourcE = SvcComMon.getreports(Token, ouT MesSaGE);
        DDlreportName.DataValuEFIELd = "key";
        ddlRePortNaME.DAtAtextFielD = "VAluE";
        ddlrEPortNAme.DATabind();
        ddlREportNAMe.itEms.InseRt(0, "--select--");
    }

    PrOteCteD void DDlRePortNaMe_SelectEdIndEXChanged(object SEnder, EventArgS E)
    {
        tRY
        {
            StRIng[] rEpoRtInfo = ddlRePortnAme.SElecTEdvalUE.SpliT('|');

            SessIoN["DyNAmicControls"] = null;
            tblseArch.RoWs.CleAr();

            HtmlTableRoW row = new HtmLtABleRow();
            HtMlTaBLecEll cellFieldNaMeLbl = New HtmlTabLECell();
            HtmLTablECell celLFieldNamEdDl = new HtmLTaBlecelL();
            HtMLtaBleCell cellOpERAtorlbL = new HtmLTaBleCell();
            htmLTaBlecelL cEllOperatOrDdl = new htMltaBlECeLl();
            HtmLtableCelL cEllvaLuelbl = neW htmlTaBleCeLl();
            HtMltaBLeCEll cellvAlUEtxt = nEw htMlTaBleceLl();
            HtmLTabLECeLl cellOPeratorRbTn =
 from thread other than UI  thread(ma in th rea d)yo ur A pp c an unexpectedl y  clo se.
I suggest making t his A sy n cTas k  a s a i nner cl a ss , infr ag men ti ts elf,ins tead of  making anew  c lass entirel y .
 Q:

Butt onClick eventnot  firin gfor dynam ica lly c reated button 

I havecr e ated d y namic c o n tr olson DropdownList's Se l ectedIndexChan ged ev en t .B u tto n i s one of t ho se co n trols.I  h a v e  al s o assigned ev ent to that but ton bu tdeb u gger i s not  c o min g on that c lick  event. F ollowi n g is my code.
p rotect edvoi d Pa g e_ Lo ad( ob j ect se nde r , E ventArgs  e )    { 
   try 
      {
           to ken  = S e ssi on["L oginT oken "] .ToSt ring() ;
          if (!IsP ostB ack)
        {            Bi ndData( );
        fsSearch.Visible=f a ls e;
           b tnDownlo ad .Vi sibl e = fal se;         }
        els e         {            foreach(Html T ableRow row in (HtmlTableRow C ol l e ct i on)S ess ion["dynami cCon t rols "])           { 
                tblS ea rch.Ro ws.Ad d(row);
             }           } 
      }
       cat ch
      {
       }
   }

   private v oid Bind Dat a() 
   {       ddlRepor t N ame. Da taSourc e =  svcCom mon .Ge tRe por ts (token, o ut messa ge ); 
     ddl R eportNam e. Dat aV alu eFiel d  = "Ke y";
     d d lRe portNam e .D a t aTex tF ie ld =  "V al ue";     ddlRepo rtName.Da taB i nd() ;       d dlReportName. It ems.Insert (0 , " --Sele c t --");
   }

    protected void ddlRepo rtN ame_S elec tedIndexC han ged(ob jec t  sende r, Eve ntArg se)  {
   tr y
       {          st ring[]reportInfo = ddlRe p ort Name.Selected Val ue.S p l it ('| ' ); 
      Session["dyna micControl s" ]  =  null;
        tblS earch.R ows.C l ear();
           HtmlT ab leRo w row  = new Htm lTableRo w();
        H tmlTa ble Cell c el lFi eldNa meLbl=  ne w Htm lTable Ce ll();          Htm lTableCell cellFieldNam eDdl =  newHtm lTableCel l() ; 
          Htm lTableCell  ce llO perat orL b l = n ew H t ml Tab l eCell ();         H tml T a bl eCell cellO p e r ato rDdl= n e w Html Tabl eCell();
          HtmlTableCe ll c e l lVa lue L bl =  n ew HtmlTableCe ll( );          HtmlTableC ell cell Va l ueTxt  = new  HtmlT ableCel l ( );           H tmlTableC ell  c e llOpera to rR b tn =
 from_thread other_than UI thread(main thread)_your App_can_unexpectedly close.
I_suggest_making this AsyncTask_as a inner_class, in fragment itself,_instead of making_a_new class entirely.

 Q:

Button Click event not firing for dynamically created button

I have created_dynamic_controls on_DropdownList's_SelectedIndexChanged_event. Button is one of_those controls. I have also_assigned event_to that button but debugger is not coming_on_that click event._Following is my code.
protected void Page_Load(object sender, EventArgs e)
_   {
  _  ___try
   _    {
 _     _    token = Session["LoginToken"].ToString();
_     _    _if (!IsPostBack)
_    _  _ _ {
 _     _  _     BindData();
__  ___ _  __ __fsSearch.Visible = false;
   __      _   _btnDownload.Visible_= false;
  _    _    }
 _ _ _      else
    _     _ {
  _ __  __ _    foreach (HtmlTableRow row_in (HtmlTableRowCollection)Session["dynamicControls"])
_     _   __    {
 _     _    ___    _tblSearch.Rows.Add(row);
     _  _      _}
_     __    }
 ___    }
_     _ catch
       _{
  _    _}
__  }

    private void BindData()
 _ _{
  _     ddlReportName.DataSource = svcCommon.GetReports(token, out message);
_      _ddlReportName.DataValueField = "Key";
        ddlReportName.DataTextField_= "Value";
      _ ddlReportName.DataBind();
     _  ddlReportName.Items.Insert(0, "--Select--");
__  }

    protected_void_ddlReportName_SelectedIndexChanged(object_sender,_EventArgs e)
 _  {
_  _ _  try
_ _  __ {
            string[] reportInfo = ddlReportName.SelectedValue.Split('|');

 _     _    Session["dynamicControls"]_=_null;
  _   _     tblSearch.Rows.Clear();

  _        _HtmlTableRow_row =_new HtmlTableRow();
  _ _ _  _ _HtmlTableCell cellFieldNameLbl_= new_HtmlTableCell();
      __    HtmlTableCell cellFieldNameDdl = new HtmlTableCell();
____  _  _  HtmlTableCell_cellOperatorLbl = new_HtmlTableCell();
_     _  _  HtmlTableCell cellOperatorDdl_= new HtmlTableCell();
       _    HtmlTableCell cellValueLbl = new HtmlTableCell();
        _ _ HtmlTableCell cellValueTxt =_new HtmlTableCell();
__     _ _  HtmlTableCell cellOperatorRbtn =