Question: I want to display output of stored procedure in HTML table. I know how to display in gridview but I do not know about displaying in HTML table. Can anyone please suggest me or provide me sample code so I can learn from it. I have searched and try to solve out. I want to create graphs from that created HTML table.

Answer: 
First of all, you have to create a ViewModel to show what information you want to list on the view. Something like this:

```
public class ProductViewModel 
{
    public int Id { get; set; }
    public string Name { get; set; }
    public decimal Price { get; set; }
    /* other properties you need */
}

```

In your controller, you could access the database and create a list and return it to a View showing in the html output.
I could recomend you to create a Data Access layer instead using Ado.Net directly in the Controller.

```
public ActionResult Index()
{
    var model = new List<ProductViewModel>();

    // create a connection
    SqlConnection con = new SqlConnection("your_connection_string");    
    try 
    {
        // open the conneciton
        con.Open();

        // prepare a command
        SqlCommand command = new SqlCommand("You_Stored_Procedure_Name",con);   
        command.CommandType = CommandType.StoredProcedure;

        // add parameters if you need
        // command.Parameters.AddWithValue("ParameterName", value);

        // execute a reader with the command
        using (var reader = command.ExecuteReader())
        {
            // loop in the result and fill the list
            while (reader.Read())
            {
                // add items in the list
                model.Add(new ProductViewModel() 
                        {
                            Id = (int)reader["Id"],
                            Name = reader["Name"].ToString(),
                            Price = (decimal)reader["Price"]
                            // other properties
                        });
            }
        }       
    }
    catch 
    {
    }
    finally 
    {   
        con.Close();
    }

    return View(model);
}

```

in your View, you could type it with the `IEnumrable<ProductViewModel>` and list it in a html table, or any html structure you need, something like this:

```
@model IEnumerable<ProductViewModel>

<table>
    <tr>
        <th>Name</th>
        <th>Price</th>      
    </tr>
    @foreach(var item in Model)
    {
        <tr>
            <td>@item.Name</td>
            <td>@item.Price.ToString("C2")</td>
        </tr>
    }
</table>

```
i think...you are able to call SP and get the data on your .CS page...

now you have to do one thing..
store that Datareader on any list.and apply the linq query so, you can get record as per your requirement.store that record on separate variable.

see Example:

```
 MainHTML = MainHTML + "<div class=" + "HideDivClass" + " id=" + TMid + "><table width=" + "180" + " cellspacing=" + "1" + " cellpadding=" + "2" + " align=" + "left" + "><tbody><tr><td style=" + "text-align:center;font-size:13px" + "align=" + "center" + " colspan=" + "2" + "><b>" + TransModeName + "</b></td></tr><tr><td class=" + "DetailsFontSize" + ">Last 7 days</td><td  class=" + "DetailsFontSize" + " " + "align=" + "right" + ">$" + TotalSumActualCharge7Days + "</td></tr><tr></tr><tr><td class=" + "DetailsFontSize" + ">Last 30 days</td><td class=" + "DetailsFontSize" + " " + "align=" + "right" + ">$" + TotalSumActualCharge30Days + "</td></tr><tr><td class=" + "DetailsFontSize" + ">This Year</td><td class=" + "DetailsFontSize" + " " + "align=" + "right" + ">$" + TotalSumActualChargeThisYear + "</td></tr><tr><td class=" + "DetailsFontSize" + ">Total</td><td class=" + "DetailsFontSize" + " " + "align=" + "right" + ">$" + TotalSumActualChargeTotal + "</td></tr><tr><td class=" + "DetailsFontSize" + ">Avg/Shipment</td><td class=" + "DetailsFontSize" + " " + "align=" + "right" + ">$" + AvgShip.ToString("#.####") + "</td></tr><tr><td class=" + "DetailsFontSize" + "align=" + "center" + " colspan=" + "2" + "></td></tr></tbody></table></div>";

```

here i took MainHTML as a string...and made a String(HTML Layout/Design format) and bind this string to label.

like. label.text = MainHTML.tostring();
you can set design as per your things...