grouping controls together

Discussion in 'ASP .Net' started by Robert Smith, Mar 31, 2008.

  1. Robert Smith

    Robert Smith Guest

    Hi,
    I have several dropdownList controls on my form and I wish to loop
    through them all and find the selected value and then concatenate them
    together into a string. The problem is I can't find a way to group the
    controls together so that I can loop through them, If I put them in a panel I
    get a compilation error.

    If wish to go
    foreach (Control MyControl in ??????)
    {
    if (typeof(mycontrol) is dropdownlist)
    {
    mystring = mystring + mycontrol.selectedvalue

    }
    }

    The problem is with the grouping together of the controls not the string
    concatenation. How can I group the controls so that I can loop through them?
    Thanx in advance

    Robert
     
    Robert Smith, Mar 31, 2008
    #1
    1. Advertising

  2. You must regroup all the controls in a Panel for example.

    And then in tour code-behind:

    foreach (Control MyControl in Panel.controls)
    > {
    > if (typeof(mycontrol) is dropdownlist)
    > {
    > mystring = mystring + mycontrol.selectedvalue
    >
    > }
    > }



    "Robert Smith" wrote:

    > Hi,
    > I have several dropdownList controls on my form and I wish to loop
    > through them all and find the selected value and then concatenate them
    > together into a string. The problem is I can't find a way to group the
    > controls together so that I can loop through them, If I put them in a panel I
    > get a compilation error.
    >
    > If wish to go
    > foreach (Control MyControl in ??????)
    > {
    > if (typeof(mycontrol) is dropdownlist)
    > {
    > mystring = mystring + mycontrol.selectedvalue
    >
    > }
    > }
    >
    > The problem is with the grouping together of the controls not the string
    > concatenation. How can I group the controls so that I can loop through them?
    > Thanx in advance
    >
    > Robert
    >
     
    2ioconseil - fabrice, Mar 31, 2008
    #2
    1. Advertising

  3. Robert Smith

    Alex Meleta Guest

    Hi Robert,

    You can use Table, Placeholder or such containers for this.

    Regards,
    Alex Meleta
    [Tech Blog: http://devkids.blogspot.com]

    RS> Hi,
    RS> I have several dropdownList controls on my form and I wish to
    RS> loop
    RS> through them all and find the selected value and then concatenate
    RS> them
    RS> together into a string. The problem is I can't find a way to group
    RS> the controls together so that I can loop through them, If I put them
    RS> in a panel I get a compilation error.
    RS>
    RS> If wish to go
    RS> foreach (Control MyControl in ??????)
    RS> {
    RS> if (typeof(mycontrol) is dropdownlist)
    RS> {
    RS> mystring = mystring + mycontrol.selectedvalue
    RS> }
    RS> }
    RS> The problem is with the grouping together of the controls not the
    RS> string concatenation. How can I group the controls so that I can
    RS> loop through them? Thanx in advance
    RS>
    RS> Robert
    RS>
     
    Alex Meleta, Mar 31, 2008
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. KatB
    Replies:
    2
    Views:
    417
    Jim Cheshire [MSFT]
    Oct 17, 2003
  2. Ken Adams
    Replies:
    1
    Views:
    366
    Jukka K. Korpela
    Mar 19, 2005
  3. Chris

    Panel css not grouping controls

    Chris, Jan 11, 2007, in forum: ASP .Net
    Replies:
    1
    Views:
    344
  4. Frank Burleigh

    Data "breaks" (or grouping) in repeating controls

    Frank Burleigh, Jul 4, 2006, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    102
    Frank Burleigh
    Jul 4, 2006
  5. AcCeSsDeNiEd

    Grouping like items together

    AcCeSsDeNiEd, Nov 15, 2005, in forum: Perl Misc
    Replies:
    9
    Views:
    190
    AcCeSsDeNiEd
    Nov 17, 2005
Loading...

Share This Page