Bikramjeet Singh

Bikramjeet Singh

  • 1.6k
  • 65
  • 2.7k

Display data horizontally in vertically issue in public method in mvc

Sep 21 2021 4:35 PM

I have a public get set list method in model class

public List<clsTradeBook> LSTList { get; set; }

I want to add data here which I am getting from database and that data showing horizontally in table, but I want to display in vertically in 3 columns like this:

      colns    Date           | Sale | Buy
               01/02/2021 0:00   0     05.6
               01/02/2021 1:00   0     15.6
               01/02/2021 2:00   0     20.6

Right now I'm adding data in List<string> ls = new List<string>(); and it display data like this 01/02/2021 0:00, 0, 05.6 in a list but I want to add data like above in

public List<clsTradeBook> LSTList { get; set; }

Here is some code in which data is adding in list view but I want in LSTList

So I need code for it so I can add it directly

public List<clsTradeBook> LSTList { get; set; }

Does anyone have an idea, then please share it with me with sample.

List<string> ls = new List<string>();
int i = 0;

for (i = 0; i < 24; i++)
{
    if (i == 0)
    {
        ls.Add(date + " " + i + ":00:00" + "," + string.Format("{0:0.00}", obj.LSTList24[0].decHH1) + ",0");
    }
    else if (i == 1)
    {
        ls.Add(date + " " + i + ":00:00" + "," + string.Format("{0:0.00}", obj.LSTList24[0].decHH2) + ",0");
    }
    else if (i == 2)
    {
        ls.Add(date + " " + i + ":00:00" + "," + string.Format("{0:0.00}", obj.LSTList24[0].decHH3) + ",0");
    }
}

clss.LSTList  = ls; 

 Regards


Answers (4)