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 934993
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T21:05:18+00:00 2026-05-15T21:05:18+00:00

What I can do: I aim to create a view where a User Control

  • 0

What I can do:
I aim to create a view where a User Control consisting of a TextBox and a Table is added to a page as needed. The user will type a SQL query in the textbox and the Table will be used to render the results.

What I need to do:
I need to add multiple of these controls to the page as the user requests them. They’ll be numbered in steps.

For example:
Step 1 = sql query to get a list of parameters;
Step 2 = sql query which uses the first parameter to return a certain value;
Step 3 = sql query that returns a cumulative sum of values which will be compared to the value in step 2.

Each time the “Add” button is clicked a new user control appears beneath the previous in which I can create my SQL query and produce my answer.

I can do the comparisons and query the database. No issues, I’m just not sure how to re-use controls in MVC.

Any suggestions would be helpful,
Thanks,
George

  • 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-05-15T21:05:19+00:00Added an answer on May 15, 2026 at 9:05 pm

    What you’re trying to do is interesting and complicated. I trust you have the logic of the solution well in hand, so I will focus on the simple question you posed: “[How can I] add multiple instances of a user control to a single view page?”

    There are, of course, a few ways you could do this. You can use javascript to clone a
    block of template html code, which is I would probably do so that I don’t have a postback. However, you didn’t mention javascript, so you should simply wrap your call to RenderPartial in a foreach loop and feed the loop with an incremental value or a list.

    View.aspx:

    <% 
    //loop over sqlQueries in list, rendering a 
    //  partial for each and passing the query into the partial.
    foreach(var item in Model.listOfSqlQueries)
        Html.RenderPartial("sqlBox", item);
    %>     
    

    Then, have a button in the view that posts to an ViewResult and returns the same list plus one item.

    Controller.cs:

    public ViewResult AddQueryBox(ViewModel viewModel) 
    {
        //Add blank sql query to list
        viewModel.listOfSqlQueries.Add(new SqlQuery());
    
        //return calling view with newly updated viewmodel
        return View("View", viewModel);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 471k
  • Answers 471k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer What happened to PayPal? They are recognized globally, use them… May 16, 2026 at 3:15 am
  • Editorial Team
    Editorial Team added an answer The float value will always just be the actual number… May 16, 2026 at 3:15 am
  • Editorial Team
    Editorial Team added an answer Float.parseFloat() will throw a NumberFormatException if the String isn't numeric… May 16, 2026 at 3:15 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.