Re: FindControl in Repeater by Lucid
Lucid
Tue May 06 14:32:37 CDT 2008
Sorry correct, if session = null... hehe.
"Lucid" <lucid@phreak2000.com> wrote in message
news:A8C53961-B30E-4A21-B2B3-FC6A8422901E@microsoft.com...
> The code below would actually overwrite the session variable every time
> its ran, but if you dont want it to do that just throw a if session !=
> null fill session with arraylist else just render the controls to the
> page.
>
>
> "Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin@gmail.com> wrote in
> message
> news:2b7ef669-fb16-471b-97c5-a33b7f01cc32@z72g2000hsb.googlegroups.com...
> On May 6, 1:57 pm, "Lucid" <lu...@phreak2000.com> wrote:
>> There is a better way of doing this, but here is an example from some old
>> code of mine that you can play with. Not sure if this is EXACTLY what you
>> are looking for, but i've found that the FindControl ability in the
>> framework is spotty at best so I throw whatever dynamic controls I make
>> into
>> a collection, in this case an ArrayList. Works well for what I was doing,
>> hopefully it points you in the right direction:
>>
>> //Make an ArrayList to hold all of the dynamic controls.
>> ArrayList controls = new ArrayList();
>>
>> //Lets make some text boxes.
>> int i = 0;
>> while (i <= 10)
>> {
>> TextBox tb = new TextBox();
>> tb.ID = i.ToString();
>>
>> /*Do here whatever you will to render the control to the page,
>> etc.
>> *
>> *
>> */
>>
>> //Add the TextBox to your array List.
>> controls.Add(tb);
>> }
>>
>> //Now just for measure if we are dependent on keeping and saving
>> that data through PostBacks, etc.
>> Session["Controls"] = (ArrayList)controls;
>>
>> //Now at a later time if we want to get the data from those text
>> boxes
>> ArrayList controls2 = (ArrayList)Session["Controls"];
>
> Hi,
>
> And what happen if the user open two windows from the same session
> (open one window from the other) ?
> You have ONLY ONE list in Session, therefore both instances willl be
> mixed together