Hi guys, im currently having troubles on my codes in C#. I want to split strings with no fix values. here' my code please help me fix this.
protected void GridViewArchives_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
DataRowView drView = (DataRowView)e.Row.DataItem;
Literal litAuthors = (Literal)e.Row.FindControl("ltAuthors");
string authors = drView["Author(s)"].ToString();
//authors = Trent Riggs:[email protected]|Joel Lemke:[email protected]
string[] splitauthors = authors.ToString().Split("|".ToCharArray());
foreach (string authornames in splitauthors)
{
litAuthors.Text = string.Format("{0}<br /><br />", authornames);
}
}
}
the problem im facing here is when i render the page it only displays one string value and does not display the succeeding string in the array.
after splitting the strings with the "|" delimeter i want to split the string with name and email address with the delimeter ":". how do i do this?