المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Looping through multiple textboxes to retrive data using a variable



C# Programming
08-07-2009, 09:21 PM
I am trying to retrieve the contents of multiple textboxes using a for loop as follows:

for (int x = 1; x < 6; x++)
{
string vDate = "txtDate" + x + ".Text"; // vDate = txtDate1.Text on 1st iteration
string vFund = "txtFund" + x + ".Text";
string outDate = vDate; // this should = txtDate1.Text on 1st iteration
string outFund = vFund;
}

When I run the code outDate = txtDate1.Text and outFund = txtFund1.Text. How do I set variable to equal the text contents of the textbox? Any help would be appreciated.

Thanks