am getting
Object reference not set to an instance of an object.
someone help me to solve this
Controller
[HttpPost]
public ActionResult Index(string txtValue, string txtLocation, string Filter_Value, int? Page_No)
{
var s = txtValue.ToString();
Session["searched"] = s;
var l = txtLocation.ToString();
Session["location"] = l;
ViewBag.plist = txtValue;
if (txtValue != null)
{
Page_No = 1;
}
else
{
txtValue = Filter_Value;
}
ViewBag.FilterValue = txtValue;
if (txtValue.Length > 0)
{
string[] keywords = txtValue.Trim().Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
string[] keyword = txtLocation.Trim().Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
var parameter = new SqlParameter[2];
parameter[0] = new SqlParameter { ParameterName = "@SEARCH", Value = txtValue };
parameter[1] = new SqlParameter { ParameterName = "@loc", Value = txtLocation };
List
using (SYTEntities context = new SYTEntities())
{
cm = context.Database.SqlQuery
}
//int Size_Of_Page = 3;
//int No_Of_Page = (Page_No ?? 1);
return View(cm.ToList().ToPagedList(Page_No?? 1, 3));
}
else
{
ViewBag.Message = true;
return View();
}
}
View:
@using (Html.BeginForm())
{
}
@if (ViewBag.Message == true)
{
}
else
{
if (Model != null)
{
if (Model.Count() != 0)
{
Searched for "@Session["searched"]"
@foreach (var item in Model)
{
@item.BusinessName
@item.FirstName
@item.BusinessCategory

Map
Description
@item.BusinessDescription
Address2
@item.Address1
Email
@item.EmailID
WorkNumber
@item.WorkNumber
MobileNumber
@item.MobileNumber
City
@item.City
State
@item.State
ZipCode
@item.ZipCode
@Html.ActionLink("Book An Appointment", "CalendarView", "Appt", new { id = @item.UserID }, null)
@*@Html.ActionLink("Book An Appointment", "Popup", "Search", new { @class = "openDialog", data_dialog_id = "aboutlDialog", data_dialog_title = "Additinal Customer" })*@
}
}
else
{
}
}
}
@Html.PagedListPager(Model, page => Url.Action("Index", new { page, txtValue = Request.QueryString["txtValue"], txtLocation = Request.QueryString["txtLocation"] }))
Replies
Know the answer? Post it — somebody with the same question will find it here.