Rank: Newbie
Groups: Authorized User, Developers, Registered Joined: 3/9/2022(UTC) Posts: 4
|
Quote:In the admin I'd like to create a list of vendors on the dashboard (works) and clicking on the vendor will bring you to the order page (works) filtered by vendors (doesn't work). I am able to successfully search by vendor on the order page. The problem I am having is that when you click on the link to the orders page, the VendorId is passed but it seems that the session is cleared sometime before the page loads. I tried creating a VendorId session but that is not working. Thanks for any help! These are the relevant modifications I made: Dashboard link Code:<a href="@Url.Action("Index", "Orders", new { VendorId = item.VendorId })"> @item.OrderCount </a>
When this loads, the VendorId has a value. Controllers\OrdersController.cs Code:
public ActionResult Index(int VendorId=0)
{
Session["VendorId"] = VendorId;
return View();
}
When I debug the Session["VendorId"] is already blank. Code:
public ActionResult OrderSearch()
{
//VENDORID IS BLANK HERE
string strVendor = Session["VendorId"] as string;
if (!String.IsNullOrEmpty(strVendor))
{
filter.VendorId = Convert.ToInt32(strVendor);
}
if (filter != null)
{
model.StartDate = filter.OrderDateStart;
model.EndDate = filter.OrderDateEnd;
model.Keyword = filter.Keyword;
model.KeywordField = filter.KeywordField;
model.OrderStatus = GetOrderStatus(filter);
model.PaymentStatus = filter.PaymentStatus;
model.ShipmentStatus = filter.ShipmentStatus;
model.OrderNumberRange = filter.OrderNumberRange;
model.VendorId = filter.VendorId;
}
Models\OrderModels.cs Quote:Code:
public class OrderSearchFilter
{
public OrderSearchFilter()
{
this.OrderIdRange = string.Empty;
this.OrderNumberRange = string.Empty;
this.PaymentStatus = OrderPaymentStatus.Unspecified;
this.ShipmentStatus = OrderShipmentStatus.Unspecified;
this.OrderStatus = -2;
this.Keyword = string.Empty;
this.KeywordField = KeywordFieldType.All;
this.VendorId = 0;
}
public int VendorId { get; set; }
}
|
|
|
|
Rank: Advanced Member
Groups: Administrators, Developers, Registered, HelpDesk, Authorized User, Admin, System Joined: 10/11/2018(UTC) Posts: 110
Thanks: 19 times Was thanked: 18 time(s) in 18 post(s)
|
Hi, Why are you converting the session value to string and then converting back to integer at first place. The following line of code is problematic: Code:
string strVendor = Session["VendorId"] as string;
You can directly convert this to int instead e.g. Code:
int vendorId = Convert.ToInt32(Session["VendorId"]);
if (vendorId > 0)
{
filter.VendorId = vendorId;
}
OR if you want it as a string update your code like this: Code:
string strVendor = Convert.ToString(Session["VendorId"]);
if (!String.IsNullOrEmpty(strVendor))
{
filter.VendorId = Convert.ToInt32(strVendor);
}
Hope this helps!
|
|
|
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.
Important Information:
The AbleCommerce Forums uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close