Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9240887
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T08:15:57+00:00 2026-06-18T08:15:57+00:00

I’m trying to iterate through a database and create a textbox for each record.

  • 0

I’m trying to iterate through a database and create a textbox for each record. Everything works just fine until I try to use the information in the controller. How do I pass this information back into the controller?

<% Using (Html.BeginForm("NewEnvCd", "Config", Nothing, FormMethod.Post))%>

    <%: Html.Hidden("Environment", Model.NewEnvironment)%>
    <div class="box" style="margin-top:30px;width:800px;">
    <h4 >Add New Environment Code</h4>
        <div>
        <div>
        <div style="float:left; text-decoration:underline;">Environment Code</div><div style="float:right;width:400px;text-decoration:underline;">Parameter Values</div>
        </div>
        <br /><br />
        <% Dim i As Int32 = 0 %>
        <% For Each cfg In Model.ParameterValues%>

            <div style="margin-bottom:5px;">

                <div style="float:left;">
                    <%: Html.Hidden("newEnvironment", Model.NewEnvironment)%>
                    <%: Html.Hidden("cfg[" & i & "].Name", cfg.Name) %>
                    <%: Html.Hidden("cfg[" & i & "].EnvCd", cfg.EnvCd) %>
                    <%: cfg.Name%>

                </div>
                <div style="float:right;">
                    <%: Html.TextBox("cfg[" & i & "]value", If(Not cfg.Value Is Nothing, cfg.Value, ""), New With {.style = "width:400px;"})%>
                </div>
                <div class="clear"></div>
            </div>
            <% i += 1 %>

        <% Next %>

        <input type="submit" value="Save" />
        <%: Html.ActionLink("Return to List", "Index", "Config") %>
        </div>
        </div>
<% End Using %>

The controller looks like this:

    Function NewEnvCd(ByVal newEnvironment As String, Optional ByVal copyEnvironment As String = "") As ActionResult
        Dim model As NewEnvCdModel
        model = New NewEnvCdModel(newEnvironment, copyEnvironment)
        Return View(model)
    End Function

    <HttpPost()>
    Function NewEnvCd(ByVal newEnvironment As String, ByVal name As String, ByVal value As String, ByVal cfg As IList(Of ConfigData.tblTT_Configuration))

        If (cfg.Count() = 0 OrElse String.IsNullOrWhiteSpace(name)) Then
            Return RedirectToAction("Index")
        End If

        For Each c In cfg
            Repository.CreateEnvironment(If(c.EnvCd, newEnvironment), c.Name, c.Value)
        Next
        Return RedirectToAction("index")
    End Function

I might have been unclear about my question, but the answer I was looking for had to do with using the name of each cfg record (ie. cfg.Name, cfg.Value, cfg.EnvCd). I was trying to pass the parameters of cfg individually (ByVal name As String, ByVal value As String,), when I should have been passing cfg as a list or queryable(ByVal cfg As IList(Of ConfigData.tblTT_Configuration)), and then pulling the values from that in the controller. Thanks for the help guys.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T08:15:58+00:00Added an answer on June 18, 2026 at 8:15 am

    Assuming that your ConfigData.tblTT_Configuration model has properties called Name, EnvCd and Value all you need to do is fix your TextBox name in order to respect the naming convention when binding to a list:

    <%: Html.TextBox(
        "cfg[" & i & "].Value", 
        If(Not cfg.Value Is Nothing, cfg.Value, ""), 
        New With {.style = "width:400px;"}
    ) %>
    

    Notice that you were missing a dot before the value.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm trying to create an if statement in PHP that prevents a single post
I am trying to loop through a bunch of documents I have to put
Let's say I'm outputting a post title and in our database, it's Hello Y&#8217;all
I am trying to understand how to use SyndicationItem to display feed which is
I am trying to find ID3V2 tags from MP3 file using jid3lib in Java.
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I am trying to render a haml file in a javascript response like so:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.