handling several textboxes in windows Phone using loops

In Desktop windows programming we can make an array of window handles and assign the hadles of edit windows to this array and then we can use a loop to extract and manage the data from edit boxes. In window Phone (Since I'm a beginner, as far as I know) you can access a text box's input text using its name. I have several text boxes and I want to extract their text using loops in pagename.xaml.cs using C#. How to do this in a simple way.

Upvotes: 0

Views: 177

Answers (1)

DotNetRussell
DotNetRussell

Reputation: 9857

You should clarify your question.

To assign data or extract data

  foreach(UIElement ele in YourGridName.Children){
        if(ele is TextBox){
            (ele as TextBox).Text = "What ever you want";
            //Or
            String text = (ele as TextBox).Text;
        }
    }

if you are trying to do it by name you can do the following

foreach(UIElement ele in YourGridName.Children){
    if(ele is TextBox){
        Switch((ele as TextBox).Name){
           case("TextBox1"):

           break;
           case("TextBox2"):

           break;
         }
    }
}

Upvotes: 2

Related Questions