[CLOSED] dynamic ID call from code behind

  1. #1

    [CLOSED] dynamic ID call from code behind

    dear support,
    i am creating a container in my code behind inside a loop for i need many.
    i am setting a dynamic ID for each container created inside the loop.
    how can i call the dynamic ID to use the Hidden="true/false" property.
    here's a snippet.

    for (int i = 0; i < table.Rows.Count; i++)
                    {
                        Ext.Net.Container nbrFieldContainer = new Ext.Net.Container();
                        string nbrFieldContId = "nbrFieldContainer_" + i;
                        nbrFieldContainer.ID = nbrFieldContId;
                        nbrFieldContainer.Layout = "ColumnLayout";
                        Ext.Net.NumberField nbrField = new NumberField();
                        Ext.Net.Label lbl = new Ext.Net.Label();
                        nbrField.ID = "nbrField_" + i;
                        nbrField.Height = 30;
                        nbrField.Width = 100;
                        nbrField.MinValue = 1;
                        lbl.ID = "nbrId_" + i;
                        lbl.StyleSpec = "margin-left:10px";
                        lbl.Text = "Days";
                        nbrFieldContainer.Items.Add(nbrField);
                        nbrFieldContainer.Items.Add(lbl);
                        nbofdays.Component.Add(nbrFieldContainer);
    
                        if (table.Rows[i]["Value"].ToString() != "" && userSettingsTable.Rows[i]["value"].ToString() != "0")
                        {
                            //I NEED TO SHOW THE CONTAINER OF ID ("nbrFieldContainer_" + i )     
                        }
                        else
                        {
                            //I NEED TO HIDE THE CONTAINER OF ID ("nbrFieldContainer_" + i ) 
                        }
    
                    }
    please note that the conditions inside my conditional statements are correct. i just need to set an ID.Hidden to true or false.

    thanks in advance
    Michel
    Last edited by Daniil; Mar 12, 2013 at 5:41 AM. Reason: [CLOSED]
  2. #2
    Hi Michel,

    Can't you do this?
    nbrFieldContainer.Hidden = true/false;
    Well, you don't need an ID if you have a control instance.
  3. #3
    Quote Originally Posted by Daniil View Post
    Hi Michel,

    Can't you do this?
    nbrFieldContainer.Hidden = true/false;
    Well, you don't need an ID if you have a control instance.
    dear Daniil,
    if i do that, all of the nbrFieldContainer in all the rows in my gridpanel will be hidden/unhidden.
    what i am doing exactly is creating a new Container in every row and giving it an ID depending on the counter inside the loop.
    if i give the container a static ID, i will be able to refer it in my code behind.
    however the ID is changing in every row.


    best.
    Michel
  4. #4
    But why the if statement is inside the loop statement if you don't need to set up the Hidden property for each statement?

    Generally, Hidden is false by default. So, setting up it to false doesn't produce any effect (unless it happens in a DirectEvent).

Similar Threads

  1. Replies: 2
    Last Post: Apr 12, 2012, 5:44 AM
  2. [CLOSED] using listener to call code behind (ajax)
    By nhg_itd in forum 1.x Legacy Premium Help
    Replies: 6
    Last Post: Sep 15, 2011, 11:56 AM
  3. Replies: 0
    Last Post: Mar 04, 2011, 12:05 PM
  4. Replies: 0
    Last Post: Mar 04, 2011, 6:46 AM
  5. how to call code behind function through grid
    By harshad.jadhav in forum 1.x Help
    Replies: 1
    Last Post: Jul 10, 2010, 9:01 AM

Posting Permissions