Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Repeating section control in ASP.NET

Reply
Thread Tools

Repeating section control in ASP.NET

 
 
Christoph Boget
Guest
Posts: n/a
 
      07-18-2004
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


 
Reply With Quote
 
 
 
 
clintonG
Guest
Posts: n/a
 
      07-18-2004
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" <> wrote in message
news:uzT#...
> 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
>
>



 
Reply With Quote
 
 
 
 
John Saunders
Guest
Posts: n/a
 
      07-18-2004
"Christoph Boget" <> wrote in message
news:uzT%...
> 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


 
Reply With Quote
 
Christoph
Guest
Posts: n/a
 
      07-18-2004
> > 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


 
Reply With Quote
 
John Saunders
Guest
Posts: n/a
 
      07-18-2004
"Christoph" <> wrote in message
news:%...
> > > 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


 
Reply With Quote
 
Dale
Guest
Posts: n/a
 
      07-18-2004
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" <> wrote in message
news:#...
> > > 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
>
>



 
Reply With Quote
 
Christoph
Guest
Posts: n/a
 
      07-18-2004
> 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


 
Reply With Quote
 
John Saunders
Guest
Posts: n/a
 
      07-18-2004
"Christoph" <> wrote in message
news:...
> > 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


 
Reply With Quote
 
Joe Fallon
Guest
Posts: n/a
 
      07-18-2004
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" <> wrote in message
news:%...
> 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" <> wrote in message
> news:#...
> > > > 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
> >
> >

>
>



 
Reply With Quote
 
John Saunders
Guest
Posts: n/a
 
      07-18-2004
"Joe Fallon" <> wrote in message
news:%...
> 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" <> wrote in message
> news:%...
> > 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" <> wrote in message
> > news:#...
> > > > > 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
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
section with in a section config file and reading that config file kampy Python 9 10-19-2012 10:59 PM
repeating section on a form? HockeyFan ASP .Net 0 05-02-2007 03:12 PM
Problem with repeating Menu Control =?Utf-8?B?RGFuaWVsIFIuIEgu?= ASP .Net 0 02-06-2006 09:29 PM
Repeating section control in ASP.NET Christoph Boget ASP .Net Web Controls 11 08-16-2004 07:58 PM
Repeating section control in ASP.NET Christoph ASP .Net 0 07-02-2004 12:57 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57