Click here to Skip to main content
16,016,537 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
List<string> ReportColumnsList = DBFunctionOBj.GetColumnNamesByReportname(Reportname);


in ReportColumnsList values getting like this
Account,EmailTo,Subject,MessageContent

but i need to display values in listbox
Account
EmailTo
Subject
MessageContent

What I have tried:

public List<string> GetColumnNamesByReportname(string Reportname)
       {
           using (var Context = new MCPEntities())
           {
               var ColumnNames = Context.Reports.Where(c => c.ReportName == Reportname).Select(c => c.ColumnNames).ToList();
               return ColumnNames;
             }
       }


  List<string> ReportColumnsList = DBFunctionOBj.GetColumnNamesByReportname(Reportname);
return Json(names, JsonRequestBehavior.AllowGet);
Posted
Updated 8-Jun-17 17:27pm
Comments
F-ES Sitecore 8-Jun-17 6:05am    
No-one is going to write your code for you, google how to call an mvc action from jQuery and you'll find code that shows how you get the list in javascript, then google how to create a listbox in jQuery and you'll get the code for that too, then just put the two together.

Use Split[^] to get an array, than use new List()[^] on that array...
 
Share this answer
 
try

public List<string> GetColumnNamesByReportname(string Reportname)
      {
          using (var Context = new MCPEntities())
          {
              List<string> ColumnNames = Context.Reports.Where(c => c.ReportName == Reportname).Select(c => c.ColumnNames).ToList();
              if (ColumnNames.Count == 1)
                  return ColumnNames[0].Split(',').ToList();
              return ColumnNames;
          }
      }
 
Share this answer
 
Comments
VenkataSeshu B 9-Jun-17 1:56am    
Thanq... it is working fine for me
Karthik_Mahalingam 9-Jun-17 6:17am    
welcome

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900