I want to show the Products like below
I have a table of houses where i am stored the Title just like {apartment in punjab} I have a Price just like 4400 and i have size just like 3 in square yard and an image so this table have all information i want to show that on my view using razor view engine how to do that
Saineshwar BageriPosted May 22, 2016, 10:35 AM
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Mvc;
using WebApplication1.Models;
namespace WebApplication1.Controllers
{
public class TestController : Controller
{
// GET: Test
public ActionResult Index()
{
List
DisplayModel d1 = new DisplayModel();
d1.DisplayID = 1;
d1.DisplayName = "ONE";
d1.DisplayAddress = "#";
DisplayModel d2 = new DisplayModel();
d2.DisplayID = 2;
d2.DisplayName = "TWO";
d2.DisplayAddress = "##";
DisplayModel d3 = new DisplayModel();
d3.DisplayID = 3;
d3.DisplayName = "Three";
d3.DisplayAddress = "###";
DisplayModel d4 = new DisplayModel();
d4.DisplayID = 4;
d4.DisplayName = "Four";
d4.DisplayAddress = "####";
DisplayModel d5 = new DisplayModel();
d5.DisplayID = 5;
d5.DisplayName = "five";
d5.DisplayAddress = "#####";
li.Add(d1);
li.Add(d2);
li.Add(d3);
li.Add(d4);
li.Add(d5);
StringBuilder homePage = new StringBuilder();
homePage.Append("
for (int i = 0; i < li.Count(); i++)
{
if (i == 0)
{
homePage.Append("
homePage.Append("
homePage.Append("
homePage.Append("
}
if (i > 0 && i % 2 == 0)
{
homePage.Append("
homePage.Append("
homePage.Append("
homePage.Append("
}
else if (i > 0 )
{
homePage.Append("
homePage.Append("
homePage.Append("
homePage.Append("
}
}
homePage.Append("
ViewBag.display = homePage.ToString();
return View(li);
}
}
Pradeep SahooPosted May 22, 2016, 10:10 AM