good morning guys, i'm developing a website. whereby have to move through records..next and previous...i did something like this
public Product NextProduct(List<Product> products, Product product)
{
Product nextproduct = (Product)product;
for (int i = 0; i < products.Count; i++)
{
if (Equals(products[i].ProductId, product.ProductId))
{
if (products[i + 1].ProductId == null)
{
return null;
}
else
{
nextproduct = products[i + 1];
}
}
}
return nextproduct;
}
public Product PrevProduct(List<Product> products, Product product)
{
Product prevproduct = (Product)product;
for (int i = 0; i < products.Count; i++)
{
if (Equals(products[i].ProductId, product.ProductId))
{
if (products[i - 1].ProductId == null)
{
return null;
}
else
{
prevproduct = products[i - 1];
}
}
}
return prevproduct;
}
this method is not working. giving error
i just wanna return the new product. how do i accomplish this...thank u in advance.