TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Raul Juarez
NA
43
0
populate controls with splitted values
Apr 5 2010 7:25 PM
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
{
}
}
}
Reply
Answers (
6
)
DEBUGG ERROR
Making your own "int" or "string" class