Error in the count

Aug 22, 2010 at 3:57 PM
Edited Aug 22, 2010 at 4:30 PM

I keep getting this error. Can someone please help me fix this?

Here is the error:

Error 1 'object' does not contain a definition for 'Count' and no extension method 'Count' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?) C:\Users\rcla39652\Documents\Visual Studio 2010\Projects\MyVideoStore\MyVideoStore\Controls\AlsoPurchased.ascx.cs 39 36 MyVideoStore

Here is some more code where the error is:

 

protected void Page_PreRender(object sender, EventArgs e)

{ 

if (_ProductId < 1)

{

 // This should never happen but we could expand the use of this control by reducing the  

 // dependency on the query string by selecting a few RANDOME products here.

 Debug.Fail("ERROR : The Also Purchased Control Can not be used without setting the ProductId.");

 throw new Exception("ERROR : It is illegal to load the AlsoPurchased COntrol without setting a ProductId.");

}

 using (CommerceEntities db = new CommerceEntities())

{

 try

{

 var v = db.SelectPurchasedWithProducts(_ProductId);

{

 throw new Exception("ERROR: Unable to Retrieve Also Purchased Items - " + exp.Message.ToString(), exp);

}

}

 if (ProductCount > 0)

{

WriteAlsoPurchased(_ProductId);

}

 else

{

WritePopularItems();

}

}

 //------------------------------------------------------------------------------------------------------------------------------------------+

 private void WriteAlsoPurchased(int currentProduct)

{

 using (CommerceEntities db = new CommerceEntities())

{

 try

{

 var v = db.SelectPurchasedWithProducts(currentProduct);

RepeaterItemsList.DataSource = v;

RepeaterItemsList.DataBind();

}

 catch (Exception exp)

{

 throw new Exception("ERROR: Unable to Write Also Purchased - " + exp.Message.ToString(), exp);

}

}

}

 

Thanks

rcla396

ProductCount = v.Count(); Here is the Error!!!!

}

 catch (Exception exp)

 int ProductCount = 0;

Aug 22, 2010 at 5:11 PM

hi there;

Hav you registered your AlsoPurchased.ascx in your ProductDetails.asx page? And did you remember to add the control to display the productid='<%# Eval("ProductID") %>' where you wnat it to appear?

 

Aug 22, 2010 at 5:18 PM

you have to also initiate this in your code in your prerender methode

int ProductCount = 0;

using (CommerceEntities db = new CommerceEntities())

 {

 try

{