So say I have a two word name in a DataRow with a space in between words. The entire name is represented as "poc" in the datarow. I can get the poc to display the full name no problem. The code looks like this :
foreach (DataRow mitRow in dtMIT.Rows)
listboxMit.Items.Add(new ListItem(mitRow["poc"].ToString()
+ " (" + mitRow["email"].ToString() + ")",
mitRow["userName"].ToString()));
Now I have code here that gets the "poc" and displays the first name and last name on the webpage:
foreach (DataRow mitRow in dtMIT.Rows)
firstNameMIT.Text = mitRow["poc"].ToString();
My question is, HOW do I write the code so that it gets only the LAST NAME after the space. The whole name format is this: John Doe
because separating the first and last name to display them in two separate text boxes is proving difficult. I have tried adding another foreach statement such as this :
foreach (DataRow mitRow in dtMIT.Rows)
lastNameMIT.Text = mitRow[" "].Tostring();
I have a char [] delimiterChars = {" "}; above everything too.
My goal is to take the values that is stored in "poc", the first and last name, then display them in separate text boxes on the webpage.