473,382 Members | 1,424 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,382 software developers and data experts.

Repeating section control in ASP.NET

When building a form using Infopath, you can define a repeating
section and stick form fields in that section. I'm curious if ASP.NET
has a similar control to make it easy to design something similar
using just ASP.NET (and not Infopath)? I'd hate to think that I'll
need to write all the javascript/dhtml to mimic that functionality and
I don't really feel the need to re-invent the wheel.
Has MS designed such a control? A 3rd party?

Thanks for your time and assistance!

Christoph
Nov 18 '05 #1
11 4115
That's one of the best reasons for learning C# as the task of using
JavaScript becomes much less of a syntax and grammar burden.

So I may have to practice what I preach as I need a form with a textbox
control that gets filled out multiple times which seems to be the only
reasonable way to build nodes in an XML document using a client-side
application.

I don't like the idea of giving away this code. I wouldn't mind so much
but I have a competitor that wants everything I have the way it is so
I was thinking about building he XML document in the ViewState
where the code could run on the server while still allowing the operator
to review and revise before a final commit.

--
<%= Clinton Gallagher
A/E/C Consulting, Web Design, e-Commerce Software Development
Wauwatosa, Milwaukee County, Wisconsin USA
NET csgallagher@ REMOVETHISTEXT metromilwaukee.com
URL http://www.metromilwaukee.com/clintongallagher/


"Christoph Boget" <jc*****@yahoo.com> wrote in message
news:uz**************@TK2MSFTNGP11.phx.gbl...
When building a form using Infopath, you can define a repeating
section and stick form fields in that section. I'm curious if ASP.NET
has a similar control to make it easy to design something similar
using just ASP.NET (and not Infopath)? I'd hate to think that I'll
need to write all the javascript/dhtml to mimic that functionality and
I don't really feel the need to re-invent the wheel.
Has MS designed such a control? A 3rd party?

Thanks for your time and assistance!

Christoph

Nov 18 '05 #2
"Christoph Boget" <jc*****@yahoo.com> wrote in message
news:uz****************@TK2MSFTNGP11.phx.gbl...
When building a form using Infopath, you can define a repeating
section and stick form fields in that section. I'm curious if ASP.NET
has a similar control to make it easy to design something similar
using just ASP.NET (and not Infopath)? I'd hate to think that I'll
need to write all the javascript/dhtml to mimic that functionality and
I don't really feel the need to re-invent the wheel.
Has MS designed such a control? A 3rd party?


Are you familiar with the Repeater and DataList controls? They can repeat
arbitrary sets of controls for you, one set per input data item.
--
John Saunders
johnwsaundersiii at hotmail
Nov 18 '05 #3
> > When building a form using Infopath, you can define a repeating
section and stick form fields in that section. I'm curious if ASP.NET
has a similar control to make it easy to design something similar
using just ASP.NET (and not Infopath)? I'd hate to think that I'll
need to write all the javascript/dhtml to mimic that functionality and
I don't really feel the need to re-invent the wheel.
Has MS designed such a control? A 3rd party?

Are you familiar with the Repeater and DataList controls? They can repeat
arbitrary sets of controls for you, one set per input data item.


I've looked at both of these and yes, they are really great for repeating
data coming from a datasource. However, what I need is something
that will repeat controls that will contain user input that will be posted
back to the server and ultimately inserted into a datastore. These are
the two things I can't figure out from reading (what little) documentation
on the repeating control:

* How to repeat a set of empty controls on the client side. For example,
let's say I have 3 input text boxes. Say, for 'First Name', 'Middle Name',
'Last Name'. And these text boxes appear on a form used to add people
to a table in the data store. I can display the first row of those blank
boxes
no problem. But I'm not show how I can make it so that the end user can
make it so that another, blank, row appears so they can add multiple people
in one shot.

* Related to the above, assuming it is possible, how would those new
controls be referenced in the code on the back end. It's easy enough to
reference the initial set of controls as I would just reference them by
name.
What would be the names of the new, dynamically generated controls (ie
the 3 input text boxes)?

The above is the context with which I was asking my original question.
I apologize for not being more clear.

Thank you for your time and assistance!

Christoph
Nov 18 '05 #4
"Christoph" <jc*****@yahoo.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
When building a form using Infopath, you can define a repeating
section and stick form fields in that section. I'm curious if ASP.NET
has a similar control to make it easy to design something similar
using just ASP.NET (and not Infopath)? I'd hate to think that I'll
need to write all the javascript/dhtml to mimic that functionality and
I don't really feel the need to re-invent the wheel.
Has MS designed such a control? A 3rd party? Are you familiar with the Repeater and DataList controls? They can repeat arbitrary sets of controls for you, one set per input data item.


I've looked at both of these and yes, they are really great for repeating
data coming from a datasource. However, what I need is something
that will repeat controls that will contain user input that will be posted
back to the server and ultimately inserted into a datastore. These are
the two things I can't figure out from reading (what little) documentation
on the repeating control:

* How to repeat a set of empty controls on the client side. For example,
let's say I have 3 input text boxes. Say, for 'First Name', 'Middle

Name', 'Last Name'. And these text boxes appear on a form used to add people
to a table in the data store. I can display the first row of those blank
boxes
no problem. But I'm not show how I can make it so that the end user can
make it so that another, blank, row appears so they can add multiple people in one shot.

* Related to the above, assuming it is possible, how would those new
controls be referenced in the code on the back end. It's easy enough to
reference the initial set of controls as I would just reference them by
name.
What would be the names of the new, dynamically generated controls (ie
the 3 input text boxes)?

The above is the context with which I was asking my original question.
I apologize for not being more clear.


Ok, no, ASP.NET doesn't do this. It's possible that you could do something
like this with ASP.NET 2.0, though I think you'd still wind up creating your
own control. See the most recent issue of MSDN Magazine for a discussion of
the new GridView control and how it works with the new DataSource controls.
It seems to me that one could have a DataSource control which would allow
you to add data client-side (perhaps as XML stored in a hidden field), but
which would then actually insert the changes into the database once the form
posted back.
--
John Saunders
johnwsaundersiii at hotmail
Nov 18 '05 #5
What you are trying to do is definitely possible in ASP.Net. It's not
exactly trivial but it also isn't terribly difficult once you get the hang
of the controls and classes involved. Undoubtedly, there are as many
possible ways to do it as there are readers of this board but if I were
doing what you're doing, I'd probably go like this:

You could create a DataSet and a Repeater. Assign a table in the DataSet as
the DataSource property of your Repeater using myRepeater.DataSource =
ds.Tables["myTable"];

Create a new row by using the NewRow method of the table and add it to the
table with ds.Tables["myTable"].Rows.Add(newRow);

Then use myRepeater.DataBind() to bind the table to your repeater. Now you
have a blank row and it will display the same template as your populated
rows but the values will be null. Make sure you test for IsDbNull and
handle that in your repeater templates.

In your ItemCommand handler of the repeater, you can save or cancel the new
row on postback and, if appropriate, create a new blank row for the next
cycle.

You could create your own repeater and inherit the
System.Web.UI.WebControls.Repeater and create your own template inheriting
the ITemplate interface.

You can find a simple example of creating your own repeater at
http://coltkwong.com/blogs/juliet/posts/467.aspx. The key thing on that
site is not her exact control but rather how simple it is to create a custom
repeater. There are probably hundreds of other custom repeater examples on
the net. I just know that I used her example as the starting point for
creating the repeater I am using in my current project at work and it has
made my life a lot easier.

Some keywords you may want to look up on google and MSDN are IsDbNull,
ITemplate, Templated Controls, DataBind, TemplateItem,
Repeater.OnDataBinding.

Hope that helps some,

Dale
"Christoph" <jc*****@yahoo.com> wrote in message
news:#N**************@TK2MSFTNGP10.phx.gbl...
When building a form using Infopath, you can define a repeating
section and stick form fields in that section. I'm curious if ASP.NET
has a similar control to make it easy to design something similar
using just ASP.NET (and not Infopath)? I'd hate to think that I'll
need to write all the javascript/dhtml to mimic that functionality and
I don't really feel the need to re-invent the wheel.
Has MS designed such a control? A 3rd party? Are you familiar with the Repeater and DataList controls? They can repeat arbitrary sets of controls for you, one set per input data item.


I've looked at both of these and yes, they are really great for repeating
data coming from a datasource. However, what I need is something
that will repeat controls that will contain user input that will be posted
back to the server and ultimately inserted into a datastore. These are
the two things I can't figure out from reading (what little) documentation
on the repeating control:

* How to repeat a set of empty controls on the client side. For example,
let's say I have 3 input text boxes. Say, for 'First Name', 'Middle

Name', 'Last Name'. And these text boxes appear on a form used to add people
to a table in the data store. I can display the first row of those blank
boxes
no problem. But I'm not show how I can make it so that the end user can
make it so that another, blank, row appears so they can add multiple people in one shot.

* Related to the above, assuming it is possible, how would those new
controls be referenced in the code on the back end. It's easy enough to
reference the initial set of controls as I would just reference them by
name.
What would be the names of the new, dynamically generated controls (ie
the 3 input text boxes)?

The above is the context with which I was asking my original question.
I apologize for not being more clear.

Thank you for your time and assistance!

Christoph

Nov 18 '05 #6
> Ok, no, ASP.NET doesn't do this. It's possible that you could do something
like this with ASP.NET 2.0, though I think you'd still wind up creating your own control. See the most recent issue of MSDN Magazine for a discussion of the new GridView control and how it works with the new DataSource controls. It seems to me that one could have a DataSource control which would allow
you to add data client-side (perhaps as XML stored in a hidden field), but
which would then actually insert the changes into the database once the form posted back.


Ok So I guess I'm just going to have to do this the old fashioned way with
DHTML, which is fine as I've done it often enough in the past. But if I do
it this way, I'm still left with my second issue/question -- how do I access
these new, dynamically created HTML form elements in the back end code?
In PHP, this was easy as I could just iterate through the $_POST (or the
$_REQUEST) arrays and just grab all the keys that matched the base name
of the control. It doesn't seem as if ASP.NET has anything close to that
for me to use. As such, I'm not sure how I'd be able to access the values
of those controls.
Just wanted to make a quick comment that I'd rather not post back to the
server to create the new row of form elements and instead create them
dynamically via the client. If I post back to create the form, accessing
the
new form elements/controls is a no brainer.

Thanks again for your time and assistance!

Christoph
Nov 18 '05 #7
"Christoph" <jc*****@yahoo.com> wrote in message
news:uE**************@TK2MSFTNGP12.phx.gbl...
Ok, no, ASP.NET doesn't do this. It's possible that you could do something like this with ASP.NET 2.0, though I think you'd still wind up creating your
own control. See the most recent issue of MSDN Magazine for a discussion

of
the new GridView control and how it works with the new DataSource

controls.
It seems to me that one could have a DataSource control which would allow you to add data client-side (perhaps as XML stored in a hidden field), but which would then actually insert the changes into the database once the

form
posted back.


Ok So I guess I'm just going to have to do this the old fashioned way

with DHTML, which is fine as I've done it often enough in the past. But if I do it this way, I'm still left with my second issue/question -- how do I access these new, dynamically created HTML form elements in the back end code?
In PHP, this was easy as I could just iterate through the $_POST (or the
$_REQUEST) arrays and just grab all the keys that matched the base name
of the control. It doesn't seem as if ASP.NET has anything close to that
for me to use. As such, I'm not sure how I'd be able to access the values
of those controls.
Just wanted to make a quick comment that I'd rather not post back to the
server to create the new row of form elements and instead create them
dynamically via the client. If I post back to create the form, accessing
the
new form elements/controls is a no brainer.


ASP.NET has the Request.Form and Request.QueryString collections, which you
can use.

You know, if you get into writing ASP.NET custom controls, you could
probably create a control which would do exactly what you want. The user
would create as many repeats of the section(s) as he wants. Then, on the
eventual postback (once per Save, perhaps), when the control loads its
postback data, it would see the number of repeats, and would be able to
create that many copies of the repeating section. It could then load the
postback data into each repeat, producing on the server a copy of the data
which was gathered on the client.

In other words, good luck, and if you get it working, please post the source
code!
--
John Saunders
johnwsaundersiii at hotmail
Nov 18 '05 #8
I agree.
I did this with a DataGrid control and a custom collection.
I have a button that says Add NewRecord.
When it is clicked I add a blank row to my collection and re-bind it to the
grid.
This works perfectly!

Joe Fallon

"Dale" <da************@msndotcomNot.Net> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
What you are trying to do is definitely possible in ASP.Net. It's not
exactly trivial but it also isn't terribly difficult once you get the hang
of the controls and classes involved. Undoubtedly, there are as many
possible ways to do it as there are readers of this board but if I were
doing what you're doing, I'd probably go like this:

You could create a DataSet and a Repeater. Assign a table in the DataSet as the DataSource property of your Repeater using myRepeater.DataSource =
ds.Tables["myTable"];

Create a new row by using the NewRow method of the table and add it to the
table with ds.Tables["myTable"].Rows.Add(newRow);

Then use myRepeater.DataBind() to bind the table to your repeater. Now you have a blank row and it will display the same template as your populated
rows but the values will be null. Make sure you test for IsDbNull and
handle that in your repeater templates.

In your ItemCommand handler of the repeater, you can save or cancel the new row on postback and, if appropriate, create a new blank row for the next
cycle.

You could create your own repeater and inherit the
System.Web.UI.WebControls.Repeater and create your own template inheriting
the ITemplate interface.

You can find a simple example of creating your own repeater at
http://coltkwong.com/blogs/juliet/posts/467.aspx. The key thing on that
site is not her exact control but rather how simple it is to create a custom repeater. There are probably hundreds of other custom repeater examples on the net. I just know that I used her example as the starting point for
creating the repeater I am using in my current project at work and it has
made my life a lot easier.

Some keywords you may want to look up on google and MSDN are IsDbNull,
ITemplate, Templated Controls, DataBind, TemplateItem,
Repeater.OnDataBinding.

Hope that helps some,

Dale
"Christoph" <jc*****@yahoo.com> wrote in message
news:#N**************@TK2MSFTNGP10.phx.gbl...
> When building a form using Infopath, you can define a repeating
> section and stick form fields in that section. I'm curious if ASP.NET > has a similar control to make it easy to design something similar
> using just ASP.NET (and not Infopath)? I'd hate to think that I'll
> need to write all the javascript/dhtml to mimic that functionality and > I don't really feel the need to re-invent the wheel.
> Has MS designed such a control? A 3rd party?
Are you familiar with the Repeater and DataList controls? They can repeat arbitrary sets of controls for you, one set per input data item.


I've looked at both of these and yes, they are really great for repeating data coming from a datasource. However, what I need is something
that will repeat controls that will contain user input that will be posted back to the server and ultimately inserted into a datastore. These are
the two things I can't figure out from reading (what little) documentation on the repeating control:

* How to repeat a set of empty controls on the client side. For example, let's say I have 3 input text boxes. Say, for 'First Name', 'Middle

Name',
'Last Name'. And these text boxes appear on a form used to add people
to a table in the data store. I can display the first row of those blank boxes
no problem. But I'm not show how I can make it so that the end user can
make it so that another, blank, row appears so they can add multiple

people
in one shot.

* Related to the above, assuming it is possible, how would those new
controls be referenced in the code on the back end. It's easy enough to
reference the initial set of controls as I would just reference them by
name.
What would be the names of the new, dynamically generated controls (ie
the 3 input text boxes)?

The above is the context with which I was asking my original question.
I apologize for not being more clear.

Thank you for your time and assistance!

Christoph


Nov 18 '05 #9
"Joe Fallon" <jf******@nospamtwcny.rr.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
I agree.
I did this with a DataGrid control and a custom collection.
I have a button that says Add NewRecord.
When it is clicked I add a blank row to my collection and re-bind it to the grid.
This works perfectly!
Note that this isn't what the OP wanted. He wanted the added data to be
client-side until the user was done with the entire form. Also, he wasn't
talking about the typical datagrid. He was talking about a group of controls
which would repeat, once per input, but which could have new repeats added
to it on the client.
--
John Saunders
johnwsaundersiii at hotmail

"Dale" <da************@msndotcomNot.Net> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
What you are trying to do is definitely possible in ASP.Net. It's not
exactly trivial but it also isn't terribly difficult once you get the hang
of the controls and classes involved. Undoubtedly, there are as many
possible ways to do it as there are readers of this board but if I were
doing what you're doing, I'd probably go like this:

You could create a DataSet and a Repeater. Assign a table in the DataSet
as
the DataSource property of your Repeater using myRepeater.DataSource =
ds.Tables["myTable"];

Create a new row by using the NewRow method of the table and add it to

the table with ds.Tables["myTable"].Rows.Add(newRow);

Then use myRepeater.DataBind() to bind the table to your repeater. Now

you
have a blank row and it will display the same template as your populated
rows but the values will be null. Make sure you test for IsDbNull and
handle that in your repeater templates.

In your ItemCommand handler of the repeater, you can save or cancel the

new
row on postback and, if appropriate, create a new blank row for the next
cycle.

You could create your own repeater and inherit the
System.Web.UI.WebControls.Repeater and create your own template inheriting the ITemplate interface.

You can find a simple example of creating your own repeater at
http://coltkwong.com/blogs/juliet/posts/467.aspx. The key thing on that
site is not her exact control but rather how simple it is to create a

custom
repeater. There are probably hundreds of other custom repeater examples

on
the net. I just know that I used her example as the starting point for
creating the repeater I am using in my current project at work and it has made my life a lot easier.

Some keywords you may want to look up on google and MSDN are IsDbNull,
ITemplate, Templated Controls, DataBind, TemplateItem,
Repeater.OnDataBinding.

Hope that helps some,

Dale
"Christoph" <jc*****@yahoo.com> wrote in message
news:#N**************@TK2MSFTNGP10.phx.gbl...
> > When building a form using Infopath, you can define a repeating
> > section and stick form fields in that section. I'm curious if

ASP.NET > > has a similar control to make it easy to design something similar
> > using just ASP.NET (and not Infopath)? I'd hate to think that I'll > > need to write all the javascript/dhtml to mimic that functionality and > > I don't really feel the need to re-invent the wheel.
> > Has MS designed such a control? A 3rd party?
> Are you familiar with the Repeater and DataList controls? They can

repeat
> arbitrary sets of controls for you, one set per input data item.

I've looked at both of these and yes, they are really great for repeating data coming from a datasource. However, what I need is something
that will repeat controls that will contain user input that will be posted back to the server and ultimately inserted into a datastore. These are the two things I can't figure out from reading (what little) documentation on the repeating control:

* How to repeat a set of empty controls on the client side. For example, let's say I have 3 input text boxes. Say, for 'First Name', 'Middle

Name',
'Last Name'. And these text boxes appear on a form used to add people
to a table in the data store. I can display the first row of those blank boxes
no problem. But I'm not show how I can make it so that the end user can make it so that another, blank, row appears so they can add multiple

people
in one shot.

* Related to the above, assuming it is possible, how would those new
controls be referenced in the code on the back end. It's easy enough to reference the initial set of controls as I would just reference them by name.
What would be the names of the new, dynamically generated controls (ie
the 3 input text boxes)?

The above is the context with which I was asking my original question.
I apologize for not being more clear.

Thank you for your time and assistance!

Christoph



Nov 18 '05 #10
> That's one of the best reasons for learning C# as the task of using
JavaScript becomes much less of a syntax and grammar burden.


Please elaborate on this? How does C# make using JS much less of
a burden?

thnx,
Christoph
Nov 18 '05 #11
For me, it was really easy to pick up on C# since I have years of experience
with js, and had been working with
VB.Net for about a year. Since the syntax for C# is a lot like js, and I was
familiar with the .net framework, picking
up C# was fairly easy to do.

Now, 2 years later, I find myself working on both C# and VB.Net projects
within the same week, or even the same
day, and have no real problems switching between the two.

I do, however, prefer to use C# over vb.Net. No real reason, it just seems
to flow better than vb.net for me.

Thx
Levi
"Christoph Boget" <jc*****@yahoo.com> wrote in message
news:e3*************@TK2MSFTNGP12.phx.gbl...
That's one of the best reasons for learning C# as the task of using
JavaScript becomes much less of a syntax and grammar burden.


Please elaborate on this? How does C# make using JS much less of
a burden?

thnx,
Christoph

Nov 18 '05 #12

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

Similar topics

1
by: suresh | last post by:
Namasivayah, Stroustrup says when indirect array is used for reordering a valarray the index cannot be repeated twice(page 679). But Nicolai Josuttis in his book on C++ standard library, page...
10
by: Brian W | last post by:
Hi All, I have a web user control that, among other things, provides Print this page, and Email this page functionality I have this script that is to execute on the click of the asp:hyperlinks ...
6
by: Ken Varn | last post by:
I want to add my own custom <STYLE> section in the <HEAD> section of my ASP.NET page within a custom control. Can someone tell me how I can have my custom control add tags to the <HEAD> section of...
0
by: Christoph | last post by:
When building a form using Infopath, you can define a repeating section and stick form fields in that section. I'm curious if ASP.NET has a similar control to make it easy to design something...
0
by: jparulan | last post by:
Hi Is it possible to parse a particular element (SECTION) from a repeating set of xml element tags. See Example below: Using XMLDOM parser. Can I achieve to get all the set of element tags...
0
by: HockeyFan | last post by:
I've used a repeater many times to display data bound to a source. However, in my case, the source is the user, and so I'm wondering what control should be used? I've got a series of questions to...
11
by: mauiboy | last post by:
programming newbie. I'm work on a program that post characters into foreground application. everything is working nicely except for repeating characters. I thought using a task timer was the way to...
0
by: marcellus7 | last post by:
Hows it going everyone. Im pretty new to Crystal Reports, and am in the process of trying to setup my first Crystal Report in my windows app. I am loading data from a DataSet, and am finally getting...
1
by: Bruce | last post by:
I have a form with repeating section using wForms (http://www.formassembly.com/blog/?p=5). I need help with the PHP to process and display multiple repeating elements if requested. PHP should send...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...

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.