Split() function isn't giving output

Total Post:108


 1304  View(s)
Rate this:

Whats wrong in the code..? It isn't working!!

Actually I want to split the entries from one of the field of database.. The items in it are separated by commas..

Here is what I am doing.

string str = dataSet.Tables[0].Rows[0]["Ingredients"].ToString();
string[] split = str.Split(',');
IList<string> lblListItemIngredients  = new List<string>();
foreach (string item in split)
and in my aspx page,
<asp:label id="lblListItemIngredients" runat="server></asp:Label>

But the output isn't coming, but in debugging mode, i can see the string is splitting.. Whats wrong?

  1. Re: Split() function isn't giving output

    Hi John, 

    try this :
      <asp:Repeater id="lblListItemIngredients" runat="server">
          <li><%#Container.DataItem %></li>

    You don't have to create a list for a data source, an array works just fine:

    string str =dataSet.Tables[0].Rows[0]["Ingredients"].ToString();
    string[] split = str.Split(',');
    lblListItemIngredients.DataSource = split;

      Modified On Apr-04-2018 06:11:37 AM


Please check, If you want to make this post sponsored

You are not a Sponsored Member. Click Here to Subscribe the Membership.