padmapriya patruni

padmapriya patruni

  • NA
  • 74
  • 117.5k

split code of 1,5,6 and 5,1-5.

Apr 10 2014 7:48 AM
my problem is whenever user clicks the 1,5,6 link button it should be split and user clicks 5,1-5  button this is should be split please find the attachment. i wrote the code for 5,1-5.it is working but whenever user clicks the5,1-5. linkbutton it is showing error please help me.i bind the details into the pagesid.

public ActionResult GetPages(string PagesId)
        {
            if (!String.IsNullOrEmpty(PagesId))
            {
                string[] split = PagesId.Split(',');
                string[] split2 = split[1].Split('-');
                var sb = new System.Text.StringBuilder();

                for (int i = int.Parse(split2[0]); i <= int.Parse(split2[1]); i++)
                {
                    sb.Append(i.ToString());
                    sb.Append(",");
                }

                string output = split[0] + "," + sb.ToString().TrimEnd(',');

Answers (5)