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
{
}
}
}
Loading
Raul JuarezPosted Apr 7, 2010, 12:30 AM
String PropertyValuesString = "Nestor20 Bergen AveClifton9738765678070112Juarez89";
Sam sounds good, answering your question:
1.How do you need to populate the text controls?
When asp.net page Load.
2.What data do you need to put where?
FirstName:S:0:6 The characters from 0 to 6
FirstName = txtNameFirst
Address = txtStreetAddress
City = txtCity
Phone =txtPhone
ZipCode = txtZipCode
AptSuite = txtAptSuite
LastName = txtNameLast
Extension = txtWorkPhoneExt
3.Does the "S" part mean anything relevant?
NO
Thanks for your help
Sam HobbsPosted Apr 6, 2010, 9:50 PM
How do you need to populate the text controls? What data do you need to put where? For example, the beginning of the data is "FirstName:S:0:6". Do you need to take the data from someplace else beginning at 0 for 6 characters and put it in a control that is for the FirstName? Does the "S" part mean anything relevant?
If that is what you need to do, then be assured that when you learn the basics of C#, it will be easy for you to do yourself. I hope you are able to get youself a good book about C#. Until then, I will help you with this, but you need to provide more information.
Raul JuarezPosted Apr 6, 2010, 1:48 PM
Sam HobbsPosted Apr 6, 2010, 1:45 PM
Raul JuarezPosted Apr 6, 2010, 1:50 AM
Sam HobbsPosted Apr 6, 2010, 1:18 AM