Re: Repeating section control in ASP.NET
From: John Saunders (johnwsaundersiii_at_notcoldmail.com)
Date: 07/18/04
- Next message: fritz: "Re: Custom validator for a pair of controls"
- Previous message: Joe Fallon: "Re: Repeating section control in ASP.NET"
- In reply to: Joe Fallon: "Re: Repeating section control in ASP.NET"
- Messages sorted by: [ date ] [ thread ]
Date: Sun, 18 Jul 2004 19:22:42 -0400
"Joe Fallon" <jfallon1@nospamtwcny.rr.com> wrote in message
news:%23Abh47QbEHA.3524@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" <daleDeletepres@msndotcomNot.Net> wrote in message > news:%23LEhAXPbEHA.2972@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" <jcboget@yahoo.com> wrote in message > > news:#N79JVObEHA.2340@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 > > > > > > > > > > > >
- Next message: fritz: "Re: Custom validator for a pair of controls"
- Previous message: Joe Fallon: "Re: Repeating section control in ASP.NET"
- In reply to: Joe Fallon: "Re: Repeating section control in ASP.NET"
- Messages sorted by: [ date ] [ thread ]