Is there a text control somewhere?

ASP controls such as radioobuttonlist and checkboxlist exist, and you can bind them to a database query. This is great for creating dynamic user interaction lists. What I'm trying to do is create a list of text fields in the same way. A list of text fields that behave the same.

The object must have a checkboxlist that is created through datasource / database. When the user finishes selecting items from this list, click the button. This list is hidden (using jquery), and a new list is created based on their selection. However, the new list is now a list of their options, followed by an empty text box. The user fills in the text fields for each record and sends it again, which binds it to the database.

SO:

checkbox - description checkbox - description checkbox - description checkbox - description 

becomes:

 Description - Textbox Description - Textbox 

The reason I'm looking for a list type control is because I can ultimately skip it to send to the database using linq. Does this make sense? My real question is whether there is still such control. I gave a full description in case anyone has other ideas besides creating a custom control.

0
source share
3 answers

There is nothing out of the box that does what you are not describing. But you can still scroll through the controls. I would put your form controls in asp: Panel or div with runat = "server" and use something like the following code to iterate over them as you described.

 foreach(Control ctl in myPanel.Controls) { //check control type and handle if (ctl is TextBox) { //handle the control and its value here } } 
0
source

asp: ListBox has a property called SelectionMode, which can be set to SelectionMode = "Multiple" and allows you to select the items you want. This is not exactly what you need, but it is a simple solution.

0
source

After the choice is made in the checkboxlist, postback to the server. Here create a datatable with two columns (description and text). For each item selected in the checkbox, add a row to this table and bind it to the gridview control. Here, the text column will always be empty. Configure gridview to use template column with text field in itemtemplate

0
source

All Articles