468,771 Members | 1,941 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,771 developers. It's quick & easy.

how to create mutiple control with same ID

wpy
Hi,

Does anybody know how to create multiple control with same ID or name in
asp.net and request the controls's value in array form? For example the vb
control can have same same but with different index.

Thanks.
Nov 17 '05 #1
1 1261
With .NET, control collections are gone (and for good reason too! ;) ). What
you can do is create an object collection and add the individual controls to
that collection and then modify them that way.

IE:

LinkButton lb1 = new LinkButton();
LinkButton lb2 = new LinkButton();
LinkButton lb3 = new LinkButton();
LinkButton lb4 = new LinkButton();

LinkButton[] linkbuttons = { lb1, lb2, lb3, lb4 };

foreach(LinkButton lb in linkbuttons)
{
lb.Text = "Hello There";
}

---or---
for(int i=0;i<linkbuttons.Length;i++)
{
linkbuttons[i].Text = "I am link button " + i.ToString();
}

HTH,

Bill P.

"wpy" <wp*@3ntity.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Hi,

Does anybody know how to create multiple control with same ID or name in
asp.net and request the controls's value in array form? For example the vb control can have same same but with different index.

Thanks.

Nov 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Shawn | last post: by
reply views Thread by saravana | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.