populate controls with splitted values
The code below splits PropertyValuesString base on the values in PropertyNames. For instance 0:8 will split the First name and the result will be Nelsonet and the same for the rest of values. What I need is to use this in an ASP.net page to populate Text boxes like txtFirstName, txtAddress, txtCity etc with the splitted values. Any help will be appreciate it.
static void Main(string[] args)
{
String PropertyNames = "FirstName:S:0:8:Address:S:8:13:City:S:21:7:Phone:S:28:10:ZipCode:S:38:5:AptSuite:S:43:1:LastName:S:44:6:Extension:S:50:2:";
String PropertyValuesString = "Nelsonet20 Bergen AveClifton9738765678070112Suarez89";
String[] PropertyNamesArray = PropertyNames.Split(':');
int Offset = 0;
int Length = 0;
int Count = 0;
Count = PropertyNamesArray.Length - PropertyNamesArray.Length % 4;
for (int i = 0; i < Count; i += 4)
{
Console.Write(PropertyNamesArray[i] + '=');
try
{
Offset = int.Parse(PropertyNamesArray[i + 2]);
}
catch (FormatException)
{
Offset = -1;
}
try
{
Length = int.Parse(PropertyNamesArray[i + 3]);
Console.WriteLine(PropertyValuesString.Substring(Offset, Length));
}
catch
{
}
}
}