473,399 Members | 3,038 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

DataList, Repeater,...?

Hi all...

I need to put 20 textbox in an aspx, but I don't want to put it
manually. How can I code a Sub to do that? Something like a For. I tried
using a For and puting the asp:textbox code inside a asp:label. It
didn't worked. Can I use DataList ou Repeater with a fixed number os
repetitions, not based on DataSet or DataTable?

Thankz,
André
Nov 19 '05 #1
4 1137
On Mon, 02 May 2005 16:09:09 -0300 in
microsoft.public.dotnet.framework.aspnet, André Nobre <no@spam.com>
wrote:
Hi all...

I need to put 20 textbox in an aspx, but I don't want to put it
manually. How can I code a Sub to do that? Something like a For. I tried
using a For and puting the asp:textbox code inside a asp:label. It
didn't worked. Can I use DataList ou Repeater with a fixed number os
repetitions, not based on DataSet or DataTable?


Hi Andre,

If you want to stick with your 'for loop' strategy, you could put a
<asp:PlaceHolder> control on your page and in your code-behind, add
each new TextBox to the Controls collection of the placeholder.

TextBox tb = null;
for (int i=0; i < 20; i++)
{
tb = new TextBox();
// customize each textbox as you see fit
PlaceHolder1.Controls.Add(tb);
}

Hope that gets you start.

Roger
Nov 19 '05 #2
Using placeholder is a solution. But generally not a wanted one. Because you
would like to display something nearby textboxes.

My advice u to use a repeater. By this way you can easily separate your
design and code.

You can use any collection to bind it. no need to use a datatable or a
dataset. For instance, just use an arraylist. And fill arraylist with
indexes.

ArrayList al = new ArrayList();
for(int i=0;i<20;i++) al.Add();
repeater1.DataSource=al;
repeater1.DataBind();

--

Thanks,
Yunus Emre ALPÖZEN
BSc, MCAD.NET

"Roger Helliwell" <rh********@telus.net> wrote in message
news:rd********************************@4ax.com...
On Mon, 02 May 2005 16:09:09 -0300 in
microsoft.public.dotnet.framework.aspnet, André Nobre <no@spam.com>
wrote:
Hi all...

I need to put 20 textbox in an aspx, but I don't want to put it
manually. How can I code a Sub to do that? Something like a For. I tried
using a For and puting the asp:textbox code inside a asp:label. It
didn't worked. Can I use DataList ou Repeater with a fixed number os
repetitions, not based on DataSet or DataTable?


Hi Andre,

If you want to stick with your 'for loop' strategy, you could put a
<asp:PlaceHolder> control on your page and in your code-behind, add
each new TextBox to the Controls collection of the placeholder.

TextBox tb = null;
for (int i=0; i < 20; i++)
{
tb = new TextBox();
// customize each textbox as you see fit
PlaceHolder1.Controls.Add(tb);
}

Hope that gets you start.

Roger

Nov 19 '05 #3
Placeholder is the best solution. Placement of the TextBox can be controlled
by using another container object (HtmlTable). Just add the textboxes in the
table and add the table to the placeholder (beauty of Controls.Add !!).
Going further- onClick event handler can be added to the TextBox control as
soon as they are created(with uniqueid).

Repeater approach may run into name conflict (ID=??). You can change the ID
attribute during the binding event. It can be done but it would be too
complex.

Prodip
www.aspnet4you.com

Read my recent article on ASP.NET-
Friday! Trace Asp.Net Application User Information
"Yunus Emre ALPÖZEN [MCAD.NET]" <ye***@msakademik.net> wrote in message
news:ul**************@TK2MSFTNGP15.phx.gbl...
Using placeholder is a solution. But generally not a wanted one. Because you would like to display something nearby textboxes.


Nov 19 '05 #4
For now I used the ArrayList solution, it was quite fast for me
(learning). I going to study PlaceHolder to know if it was the best
choice for that case.

Thanks for the answers,
André
Hi all...

I need to put 20 textbox in an aspx, but I don't want to put it
manually. How can I code a Sub to do that? Something like a For. I tried
using a For and puting the asp:textbox code inside a asp:label. It
didn't worked. Can I use DataList ou Repeater with a fixed number os
repetitions, not based on DataSet or DataTable?

Thankz,
André

Nov 19 '05 #5

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

Similar topics

6
by: Gav | last post by:
Hi All, I have created a datalist using the repeatcolumns property to create multiple columns. I have tried to keep everythings width to 100% so that if the window is resized it still looks...
6
by: Thanh | last post by:
I created an ASP.NET project and dropped a DataList on the web form. I then wrote a simple class to return data: namespace Playing { public class PositionData { private string name; private...
0
by: Shun Duke | last post by:
I have working code allowing me to nest repeaters inside datalists using relations and child rows but this does not allow me to acheive my goal. What I want to be able to do is display small...
5
by: Ben Fidge | last post by:
I'm using DataList to present tabular data but am often having problems with some rows column alignment being out of synch with the rest of the rows. My DataList looks similar to this...: ...
2
by: Stimp | last post by:
I would like to produce something like: http://redwoodestates.co.uk/forrent.aspx It's either a datalist/repeater/datagrid, but it is broken up into sections ("1 bedroom", "2 bedroom", etc...)...
2
by: serge calderara | last post by:
Dear all, I have make some basic testing on Repeater and DataList object. I have notice for sure that if your database retrive data contains 3 records, then both controls will repeat the...
1
by: Simon Cheng | last post by:
When I tried to display data in datalist and repeater, the first data item always disappears in all datalist and repeaters in my web forms. The code I use for the html page is: <TD...
3
by: GD | last post by:
I'm using a DataList and a Repeater (nested in the DataList) to display a list of "Chapters" and "Documents" within the Chapters. <asp:DataList ID="dlChapter" Runat="server" RepeatColumns="2"...
3
by: rn5a | last post by:
I want to change the background color of a row in a DataList when the mouse is moved over a row. This is how I tried but it doesn't change the background color of a row in the DataList when the...
2
by: Paulo | last post by:
What is DetailsView, FormView, DataList, Repeater components? Any differences? VS 2005 asp.net C#
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.