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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T13:03:51+00:00 2026-05-28T13:03:51+00:00

I have multiple textboxes in my form like txtTask0, txtTask1… txtTask12. so I want

  • 0

I have multiple textboxes in my form like txtTask0, txtTask1… txtTask12.

so I want to pass values of those textboxes into my webservice one by one.

for (int i = 0; i <= 12 ; i++)
{
   sOUT = ws_service.InsertAchievement(i,txtTask0.Text,txtAchieve0.Text);              
}

Here instead of passing txtTask0.text I need to pass the “i” value one by one like

txtTask[i].text

something similar to this

TextBox tb = (TextBox) Controls["txtTask" + i];

from this link
But that code results in error like

Error   92  The best overloaded method match for 'System.Web.UI.ControlCollection.this[int]' has some invalid arguments 

How can I pass multiple textbox values into the loop.?

  • 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-28T13:03:52+00:00Added an answer on May 28, 2026 at 1:03 pm

    You cant do like that, because the Controls[index] expects an integer as its parameter, but you are passing a “string concatenated with an integer” it wont work, instead you do like below it will work, hope it will help you…

                foreach (Control c in this.Controls)
                {
                    int i = 0;
                    if (c is TextBox)
                    {
                        while(i < 10)
                        {
                            if (c.Name == "txtTask" + i)
                            {
                                MessageBox.Show("This is textBox" + i);
                            }
                            i++;
                        }
                    }
                }
    

    EDIT :

    If the condition if(c is TextBox) is not parsing correctly then do like

               foreach (Control c in this.Controls)
                {
                    int i = 0;
                    while (i < this.Controls.Count)
                    {
                        if (c.Name == "txtTask" + i)
                        {
                            MessageBox.Show("This is textBox" + i);
                        }
                        i++;
                    }
                }
    

    EDIT 2:

    Or Simply if you want to loop out in all textbox controls in aspx page use this following code part. It works very perfectly..

            int count = 0;
            foreach (Control c in this.Page.Controls)
            {
                foreach (Control c1 in c.Controls)
                {
                    int i = 0;
                    if (c1 is TextBox)
                    {
                        while (i < 10)
                        {
                            if (c1.ID == "TextBox" + i)
                            {
                                count++;
                            }
                            i++;
                        }
                    }
                }
            }
            Label1.Text = count + " textbox(es) has been found";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have multiple readonly textboxes like this <div id=box> <form method=post action=> <input type=text
I have a form with multiple textboxes with the same names. I want to
I have a web form that has multiple ListBoxes, TextBoxes, DropDowns. If I put
I have multiple input textboxes in my page. I want to reset particular text
I have a form with multiple textboxes on and a datatable, the datatable is
I have a form with multiple textboxes which are created dynamically, now all these
I have a gui form, where multiple text boxes are present. I want to
I have a form with multiple textboxes and number of textboxes do change depending
If I have multiple textboxes which have different ID's but all id's start with
I have a XAML window with multiple TextBoxes, each with a corresponding TextBlock tag

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.