Need help with C# code

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Durango2008

    Need help with C# code

    Hi, I have a form which contains a table(Table1), within that table I have
    label with an ID set to "1A".
    Using something like:

    if(Table1.FindC ontrol("1B") != null)
    {
    labelID = "1C";
    }
    else if(Table1.FindC ontrol("1A") != null)
    {
    labelID = "1B";
    }

    Label lblType = new Label();
    lblType.ID = labelID;

    TableRow tr = new TableRow();

    TableCell tc = new TableCell();

    tc.HorizontalAl ign = HorizontalAlign .Center;

    tr.Controls.Add (tc);

    tc.Controls.Add (typeLabel);

    Table11.Control s.Add(tr);

    So whenever this code runs if it finds the latest Label for example "1B" it
    will add a new tr and cell with an updated label "1C" or if it finds "1A" it
    will update with new label "1B".

    It does work with the initial label that is set in the .aspx file however
    when run it again it will not find the new label to reupdate things.

    Anyone have any suggestions?

    thank you for any advice.


  • pipo

    #2
    Re: Need help with C# code

    What do you mean by 'run it again'??
    When Postbacking...
    the whole Page will be new, so make sure to add your newly created control
    as well otherwise it will not exists.




    "Durango200 8" <el_durang0@yah 00.c0mschreef in bericht
    news:b8zBj.1688 4$0o7.2341@news svr13.news.prod igy.net...
    Hi, I have a form which contains a table(Table1), within that table I have
    label with an ID set to "1A".
    Using something like:
    >
    if(Table1.FindC ontrol("1B") != null)
    {
    labelID = "1C";
    }
    else if(Table1.FindC ontrol("1A") != null)
    {
    labelID = "1B";
    }
    >
    Label lblType = new Label();
    lblType.ID = labelID;
    >
    TableRow tr = new TableRow();
    >
    TableCell tc = new TableCell();
    >
    tc.HorizontalAl ign = HorizontalAlign .Center;
    >
    tr.Controls.Add (tc);
    >
    tc.Controls.Add (typeLabel);
    >
    Table11.Control s.Add(tr);
    >
    So whenever this code runs if it finds the latest Label for example "1B"
    it will add a new tr and cell with an updated label "1C" or if it finds
    "1A" it will update with new label "1B".
    >
    It does work with the initial label that is set in the .aspx file however
    when run it again it will not find the new label to reupdate things.
    >
    Anyone have any suggestions?
    >
    thank you for any advice.
    >

    Comment

    • Durango2008

      #3
      Re: Need help with C# code


      "pipo" <nomail@me.comw rote in message
      news:OnFUC25gIH A.4320@TK2MSFTN GP06.phx.gbl...
      What do you mean by 'run it again'??
      When Postbacking...
      the whole Page will be new, so make sure to add your newly created control
      as well otherwise it will not exists.
      >
      I do add the new control with the lines:
      TableRow tr = new TableRow();
      TableCell tc = new TableCell();
      tc.HorizontalAl ign = HorizontalAlign .Center;
      tr.Controls.Add (tc);
      tc.Controls.Add (typeLabel);
      Table11.Control s.Add(tr);

      Did you mean something else?


      Comment

      • pipo

        #4
        Re: Need help with C# code

        What do you mean by 'run it again'??


        "Durango200 8" <el_durang0@yah 00.c0mschreef in bericht
        news:zfOBj.1621 5$xq2.11470@new ssvr21.news.pro digy.net...
        >
        "pipo" <nomail@me.comw rote in message
        news:OnFUC25gIH A.4320@TK2MSFTN GP06.phx.gbl...
        >What do you mean by 'run it again'??
        >When Postbacking...
        >the whole Page will be new, so make sure to add your newly created
        >control as well otherwise it will not exists.
        >>
        >
        I do add the new control with the lines:
        TableRow tr = new TableRow();
        TableCell tc = new TableCell();
        tc.HorizontalAl ign = HorizontalAlign .Center;
        tr.Controls.Add (tc);
        tc.Controls.Add (typeLabel);
        Table11.Control s.Add(tr);
        >
        Did you mean something else?
        >
        >

        Comment

        • Durango2008

          #5
          Re: Need help with C# code


          "pipo" <nomail@me.comw rote in message
          news:%23vsQf1Fh IHA.3780@TK2MSF TNGP06.phx.gbl. ..
          What do you mean by 'run it again'??
          >
          I meant postback sorry for confusion.


          Comment

          Working...