hello,
i write the comment in partial view where is the problem
i have this data access which returns 4 images from sql server
public DataTable SelectAllAdsImages()
{
using (SqlConnection con = new SqlConnection(constring))
{
using (SqlCommand cmd = new SqlCommand("sp_adsimages", con))
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@Action", "SelectAll");
DataTable dt = new DataTable();
con.Open();
dt.Load(cmd.ExecuteReader());
con.Close();
return dt;
}
}
}
controller which get the data and pass data table to partial view
public ActionResult detailslider()
{
//Call first category in top category menu partial layout
//DataTable ds = new DataTable();
var id = HttpContext.Request.RequestContext.RouteData.Values["id"];
ImagesBL sliderbl = new ImagesBL();
//ds = fc.SelectFirstCategoriesBL();
//Fille properties of contractIdetails
return PartialView("detailslider", sliderbl.SelectSliderBL(int.Parse(id.ToString())));
}
partial view
@using System.Data
@model DataTable
@foreach (DataRow row in Model.Rows)
{
<div class="main-img">
// here it should not loop only get first image from data table
<img src="@row["ImagePath"]" class="img" id="current" />
</div>
<div class="imgs">
// here it should loop the data and bind to image
<img src="@row["ImagePath"]" class="img" />
</div>
}