Creating a form dynamically with a Repeater

H

hardieca

Hi,

I'm building a multi-lingual CMS. The user can add as many languages as
he likes. The user will be able to create sections for different
content (General, News Releases, etc...) in the db table tblSection.
For each section, the user will have to input the section name for each
language he is supporting in tblSectionLang.

So, if the user has a section called News, and he is supporting English
and French, two records will have to be inserted into tblSectionLang -
News and Nouvelles.

My first instinct was to use the gridview to display/create the parent
section object, and once a parent section object was created or
selected, I would use the Repeater control to check the number of
languages the CMS supports, and then render the appropriate number of
input fields. I've been toying with creating the controls dynamically
in a repeater's ItemTemplate, but the I don't understand how the IDs
are being generated, so I don't know how I can access their values. The
ItemTemplate I'm assigning looks something like this:

public class SectionItem : ItemTemplate
private counter = 0;
public void InstantiateIn(Control container)
{
TextBox tb = new TextBox();
tb.ID = "txtStatus" + counter.ToString();
counter += 1;
*SNIP*

I'm getting the appropriate input fields on my page, but the IDs are
emitted as Repeater1_ctl13_txtStatus1, Repeater1_ctl115_txtStatus2,
Repeater1_ctl17_txtStatus3, etc...

Am I on the right track with this? Is there an easy way to access the
values of these dynamically rendered input fields? How do I know what
the IDs will be?

Regards,

Chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top