473,846 Members | 1,983 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

iterate through set of controls in code behind on postback

Let's say I rendered a bunch of controls with the same name and different IDs.
On postback, can I somehow iterate through these controls (checkboxes in
this case, but could be dropdown controls in the future) and get their values
and IDs
with all this done in the code behind page?
A small example would be appreciated.
Thanks,
Oleg
Nov 19 '05 #1
2 1947
Sure, but you would want to use a recursive function to do this ideally, as
you may have nested Controls. Every Control has a Controls Collection, which
you can, of course, loop through. So, you create a function that takes a
Control as a parameter, loops through each of the Controls in its Controls
Collection, and calls itself for each Control.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
The sun never sets on
the Kingdom of Heaven

"Oleg" <Ol**@discussio ns.microsoft.co m> wrote in message
news:49******** *************** ***********@mic rosoft.com...
Let's say I rendered a bunch of controls with the same name and different
IDs.
On postback, can I somehow iterate through these controls (checkboxes in
this case, but could be dropdown controls in the future) and get their
values
and IDs
with all this done in the code behind page?
A small example would be appreciated.
Thanks,
Oleg

Nov 19 '05 #2
I did something like this

Private Sub seperateControl s(ByVal Cntrl As Control)

If Cntrl.Controls. Count > 0 Then

Dim contrl As Control
For Each contrl In Cntrl.Controls

seperateControl s(contrl)

Next

Else
'setTooltipValu e(Cntrl)
End If

End Sub

--
http://pathidotnet.blogspot.com
=====
vInAypAtHi
o__
---_,>/'_------
(_) \(_)
---------------
"Oleg" wrote:
Let's say I rendered a bunch of controls with the same name and different IDs.
On postback, can I somehow iterate through these controls (checkboxes in
this case, but could be dropdown controls in the future) and get their values
and IDs
with all this done in the code behind page?
A small example would be appreciated.
Thanks,
Oleg

Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
5324
by: theComputer7 | last post by:
I cut down the code to make this half way understandable... I have read Data Grid girls caution about over use of dynamic controls. I truly believe what I am doing requires dynamically inserted user controls. Worse I'm trying to add dynamic user controls from within a repeater loop (looping through attributes)... I bind to a function in the code behind and pass in the attribute. <asp:repeater id="rAttributes" Runat="server">
3
3009
by: Cathie | last post by:
Hi All, I have a few user controls on a page and I need to determine which control caused the PostBack. Is there anyway to do this? Thanks in advance, Cathie
4
7240
by: Tom Wisnowski | last post by:
Hello all, Here is a simple example of what I'm doing... Create a ASPX page Add a PlaceHolder(plch) and a Button(btn) to the page. In the code behind on Page_load add the following... TextBox txt = new TextBox(); if(!IsPostBack)
1
2142
by: Robert Howells | last post by:
Perhaps I'm just too new at this to pull it off, or perhaps it's just bad architecture. I'd appreciate some feedback on the the wisdom (or lack thereof) in attempting the following: I'm not new to programming, but I am new to ASP.NET and Web application design in general... loved the concept of user controls and dynamically adding them to a page. So what I wound up with was an application that dynamically loads two user controls directly...
4
6733
by: Chuck Ritzke | last post by:
Hi, I've searched the newsgroup and other sources to understand how to handle runtime controls and see I'm not the only one who's confused, but I'm still not quite sure of the best way to handle from all the various explanations/answers. I'm attempting the typical scenario... I create a variable number of controls at runtime based on parameters from a database.
0
1337
by: Sue | last post by:
I'm missing something very simple here, and I need an answer fairly quick if possible. I'm behind on this project now because of this... Code examples below question... I have a datagrid (DG) that I've pared down to the bare essentials. The two controls involved (MyButton and MyValue) are created in the DG_ItemCreated sub and added to the two placeholders in the datagrid. If the button is clicked, the DG_ItemCommand grabs the button's
1
1806
by: Mike | last post by:
Hi, I am having troubles dealing with dynamically created WebControls. I have this HTML code: <form id="Form1" runat="server" method="post"> <table width="960" align="center"> <tr> <td align="center"> ......
1
1606
by: Bjorn Sagbakken | last post by:
With ASP.NET 2.0: I have managed to create controls dynamically in an asp:table, populating them with database info, and even adding empty rows of controls for adding new data to the database. For all this to work I add a ViewState counter, so far so well. But I also want to clear the form, remove the controls and remove all ViewState data. This is done with some code behind a button. I have tried various kind of commands, and they...
4
4769
by: =?Utf-8?B?RHlsYW5TbWl0aA==?= | last post by:
I have a WebForm where I'm dynamically creating some controls and I'm having difficulty understanding how the state is being persisted and how to work with it. I've created a simplified example to demonstrate my issues. Lets say I have a WebForm with a DropDownList where the user selects a number from 1 to 10 (the DropDownList is not dynamically created). I also have a button on there that I use to trigger a PostBack. Based on the...
0
9879
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9725
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10640
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9477
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7877
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7050
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5714
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5906
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4521
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.