I have fetched data from datatable using stored procedure. Now I don't know how to bind them into HTML controls in my view. I am using MVC framework. Here is my code from where I am calling web service.
$('#btnSearch').click(function () {
alert('in search function');
$.ajax({
type: "POST",
url: location.pathname + "SearchFromHome.asmx/SearchFromHomeBus",
data: "{fromid:'" + 1 + "' , toid:'" + 2 + "'}",
dataType: "json",
contentType: "application/json; charset=utf-8",
success: SearchSuccess,
error: SearchError
});
Here is my web method :
public IEnumerable<CitySearchResult> SearchFromHomeBus(int fromid, int toid)
{
SqlParameter []para=new SqlParameter[2];
para[0]=new SqlParameter("@city1",fromid);
para[1]=new SqlParameter("@city2",toid);
using (cab_4_21Entities1 d = new cab_4_21Entities1())
{
ObjectResult<CitySearchResult> search =d.ExecuteStoreQuery<CitySearchResult>("usp_SearchcabResult @city1, @city2", para);
List<CitySearchResult> searchResult=search.ToList<CitySearchResult>();
return searchResult;
}
}
In this web method I have used entity framework. But I don't want to use it further because I am not comfortable with it. So, if I use stored procedure and store retrieved data into datatable, How to bind that data into HTML controls in the view?