none
Pivot viewer showing the image multiple times

    Question

  • I've a table called views where it has multiple datas related to one item(many to One relationship).When I try to display it on my pivot viewer it displays the item image multiple times based on the reference they have in views table.if item1 has 3 views then it displays the item image 3 times.How do I show one image and all references to it as facet.

    Any suggestion is much appreciated.

    Thursday, May 03, 2012 10:28 AM

Answers

  • Hi Vidhya,

     Instead of using a Guid  or any type at all, i think we can just use var .  Change your code to something line this.

    var products = (from p in m_dataContext.Table_2s
                                    select p.itemid);
                    foreach (var v in products)
                    {
                    }
    

    That should resolve all the Guid related errors .  Hope it helps.

    Wednesday, May 09, 2012 5:13 AM
  • Hi ,

      Take a global count variable. It should keep track of that tempdata index . :)

     

                      var resources = from r in datacontext.item_tables 
                                      select r.itemID;  
                                   
                      Collection collection = new Collection();  
                      collection.Name = "Items";  
       
                      Guid[] ar= resources.ToArray<Guid>();  
    
    
                      int count=0;   //  This should solve it ,  or you can place those ftemp[0] ,ftemp[1] inside the loop 
    
                      foreach (Guid i in ar)  
              
                      {  
        
                       var prod = (from r in datacontext.item_tables  where r.itemID == i select r);  
                      
                       Dictionary<Guid, item_tables> tempdata =prod.ToDictionary(s => s.itemID);  
              
                       Facet[] ftemp = new Facet[tempdata.Count];  
                    
                       string s1 = "";  
                        
                       ftemp[0] = new Facet("descriptiob", FacetType.Text, tempdata[count].Description);  
      
                       ftemp[1] = new Facet("date", FacetType.Text, tempdata[count].uploaddate);  
      
                        
                       for (int iv = 0; iv < tempdata.Count; iv++)  
                       {  
       
                           s1 += tempdata[iv].ProductName + " \n";   
                       }  
      
                       ftemp[2] = new Facet("ProductName", FacetType.Text, s1);  
      
                       collection.AddItem(tempdata[count].ItemName, null, null,  
                                 
                                     ftemp[0], ftemp[1], ftemp[2] );  
                       
                       count ++ ;
                     
                       }

    Hope it HelpsLaughing

    Sunday, May 20, 2012 11:48 PM
  • Hi Vidhya, 

         It means you have to reset the x value before it starts processing the second row.  So in the last statement of the loop (where you are going to process the next row), write x=0;  This will solve your out of bounds issue.

    Hope it Helps Laughing

    Tuesday, May 22, 2012 8:32 PM
  • Hi Phani,

             Found the solution.This info might help you.I replaced my below code

    var resources = from r in datacontext.item_tables

                                      select r.itemID;

    var resources = (from r in datacontext.item_tables

                                      select r.itemID).Distinct();

    that removed the selection of itemid several times to once.But still was showing "Index ouside bounds error" I fixed it by replacing my forloop  to

     for (int iv = 0; iv <=(tempdata.Length-1); iv++)

    {

        s1 += tempdata[iv].ProductName + "/";

     

    }

    and now my index error on forloop was solved and started showing "Index outside bounds" error in facet declaration, I changed facet array as

         Facet[] ftemp = new Facet[5];

    as i had ftemp[0],ftemp[1],ftemp[2],ftemp[3],ftemp[4].

    That it all my error solved and got one image in my pivot.

    Thank you so much Phani for your wonderfull help and valuable suggestions.

    Friday, May 25, 2012 11:58 AM

All replies

  • Hi Vidhya,

        If you are modifying and using the PivotJitServer project for creating your collection then i suggest you do the following.

       1)  Go to the CollectionFactories project, and open the SqlAdventureWorks.cs  (or whatever your similar file is named )

       2) In the MakeCollection method, you have code like this

          var products = from p in m_dataContext.Products where p.ListPrice > 0 select p;

       Instead of this simple query, you can change it to select distinct id's first .  ( instead of select p, get the p.id or something similar )

     3)   Then in a loop, for each of the id's,  try fetching the objects and adding them as facets .

     This way , you will have a single image for each of the id , and all the other properties you want can be assigned as facets.

    This is just the rough idea.  I will try making some sample code tomorrow.

     Hope it helps. Laughing

     

    Thursday, May 03, 2012 12:39 PM
  • Hi Vidhya ,

       What happened ? Are you using the PivotJitServer project  or not ? 

       Have you tried implementing that idea ?  Just wanted to confirm before i start coding.

       It will help if you can provide some sample data also .

     

     

    Friday, May 04, 2012 4:44 AM
  • Hi,

     Here is the skeleton code anyway.  Change this accordingly.

     

    Collection collection = new Collection();
    collection.Name = "Custom database";
    
    //Getting Id's  
    
    var products = (from p in m_dataContext.Table_1s
                   select p.Sno).Distinct<int>();
    
    //Storing the id's in an array
    int[] ar = products.ToArray<int>(); 
    
    // This runs once for each id, so you will get max of 1 image per item id
    
      foreach (int i in ar) 
      { 
         var vals = from p in m_dataContext.Table_1s
                    where p.Sno == i
                    select p;
         Table_1[] tempdata = vals.ToArray<Table_1>();
    
         Facet[] ftemp= new Facet[tempdata.Length];
         
         ItemImage image = null; 
              
         for(int iv =0; iv<tempdata.Length;iv++)
            
         {
            // create your facets  and store them to the facets array
    
         } 
       // set the itemImage   
       // add to the collection here
      
     }
    

    Please note that my Dbml file contains only 1 table .. Table_1 , with structure Sno,Marks,TestNo.  The sample data i have is like  

    Sno Marks  TestNo  

    1  10  1

    1  14  2

    2  7    1

    2  18  2  

    My intention is to group the first 2 records and display 1 image for Sno=1  and one for Sno=2

    Hope it Helps Laughing

     

    Friday, May 04, 2012 5:52 AM
  • Hi Phani,

             Thank you so much for coming forward to help me.Sorry I din't check your reply since I was caught in other work.I'm using a view to display these data's in my  pivot my code is.In my below code I need my perspectivename is the one which has one or more references.My issue here is PerspectiveID is a GUID which is not an integer.How do i handle this in Linq to sql.

          public override Collection MakeCollection(CollectionRequestContext context)
            {
                ResourcesDataContext datacontext = new ResourcesDataContext();
               
    
    
    
    
                const int maxItems_c = 150;
                try
                {
                    var resources = from r in datacontext.ItemsINPIVOTs
                                    select r;
    
    
                    Collection collection = new Collection();
                    collection.Name = "ItemCollections";
    
                    foreach (var user in resources.Take(maxItems_c))
                    {
    
                        collection.AddItem(user.Name, null, null,
                            new ItemImage(new Uri(user.location)),
                            new Facet("Summary", user.Description),
                            new Facet("Chronological", user.uploaddate),
                             new Facet("Perspectives", user.ItemName),
                            new Facet("Contributor", user.username)
                            );
    
    
    
                    }
                    collection.SetFacetDisplay("Summary", false, true, false);
    
                    
                    return collection;
                }
                catch (Exception ex)
                {
    
                    return ErrorCollection.FromException(ex);
                }
            }

     

       

    Sunday, May 06, 2012 4:33 PM
  • Any Help guys?

    Monday, May 07, 2012 11:02 AM
  • Hi Vidhya, what are you using to determine whether two entries belong to the same item or not ? Do you have any other table that maps the perspective guid to the item ?
    Monday, May 07, 2012 10:43 PM
  • Hi Phani,

     I've a Item table where an item can have mulitple products associated to it.I'm working on multiple tables where all the tables have itemid as foreign key.My Item table is the parent table.My product tables is a bridge table which holds  itemid and multiple productid asociated to one item id.Please NOTE: all my id's are GUID datatype which is supported by LINQ-SQL.I've created a view which holds all the data's from multiple tables.Could you plz guide me how shold I proceed with my code.I'm stuck with this for a long time.From my below eg. I need one image for my itemid but with all datas.

    something like

    itemid    Productid

    1               007

    1               678

    1               004

    1               689

    2               485

    2               758

    2               756

     

    Tuesday, May 08, 2012 8:02 PM
  •   Hi Vidhya,

        I dont think it matters if your id is GUID or int.  According to your data, there are 2 tables we are concerned about.  

       The primary table that has the item guid, item details etc.     Now this was my earlier code.

       

       var products = (from p in m_dataContext.Table_1s 
                   
    select p.Sno).Distinct<int>(); 
     
    //Storing the id's in an array 
    int[] ar = products.ToArray<int>();  
     
    // This runs once for each id, so you will get max of 1 image per item id 
     
     
    foreach (int i in ar)  
     
    {  
         
    var vals = from p in m_dataContext.Table_1s 
                   
    where p.Sno ==
                   
    select p; 

      

     replace the int to GUID , 

     

    var products = (from p in m_dataContext.Table_1s
                   select p.Sno).Distinct<Guid>();
     
    //Storing the id's in an array
    Guid [] ar = products.ToArray<Guid>(); 
     
    // This runs once for each id, so you will get max of 1 image per item id
     
      foreach (Guid i in ar) 
      { 
         var vals = from p in m_dataContext.Table_1s
                    where p.Sno == i    // Just check here once if you can compare two guid's like this , or convert them to string
                    select p;
     

    Please try this out.

    Hope it Helps Laughing

    Wednesday, May 09, 2012 12:27 AM
  • Hi Phani,

              It shows error when i try to use distinct<GUID>(); and i learnt that using guid in linq to sql is not supported widely and I'm also not sure what data's should be inside the for loop.Please help.

    Wednesday, May 09, 2012 4:10 AM
  • Hi Vidhya,

       What error is it showing ?  And by the way, what are you trying to select , the GUID column or the entire row ?  the Distinct<Guid>  works only when you select a guid column .

    Hope it Helps Laughing

    Wednesday, May 09, 2012 4:19 AM
  • the error msg is "system.Guid does not contain definition for Distinct" .I need to select the entire column which is a guid column,Unfortunately i could not use any string column b'coz they are not unique.

    Wednesday, May 09, 2012 4:30 AM
  • hi Vidhya,

      My intention for selecting Distinct was that i should first get all the item ids. And then, for each item id, i need to iterate the various elements to group them. 

     But here, you already have the itemids in your item table. Obviously they are unique, so you can just get the itemids  into an array.  Then use the second loop to iterate through the product table .

    Collection collection = new Collection(); 
    collection.Name = "Custom database"; 
     
    //Getting Id's   
     
    var products = (from p in m_dataContext.item_table                select p.itemId). 
    
    Guid [ ] ar = products.ToArray<Guid>();  
     
     
      foreach (Guid i in ar)  
      {  
         var vals = from p in m_dataContext.product _table                 where p.Sno == i 
                    select p; 
         Table_1[] tempdata = vals.ToArray<Table_1>(); 
     
         Facet[] ftemp= new Facet[tempdata.Length]; 
          
         ItemImage image = null;  
               
         for(int iv =0; iv<tempdata.Length;iv++) 
             
         { 
            // create your facets  and store them to the facets array 
     
         }  
       // set the itemImage if present   
       // add to the collection here 
       
     }

     Hope it Helps Laughing

    Wednesday, May 09, 2012 4:43 AM
  • I too had the same doubt but still not very handy using GUID and LINq-SQL.What should be the format of creating facet inside forloop? sorry for keeping you on hold with this issue.

    Wednesday, May 09, 2012 4:49 AM
  • Again with Array the same error on using GUID.

    Wednesday, May 09, 2012 4:54 AM
  • Hi Vidhya,

     Instead of using a Guid  or any type at all, i think we can just use var .  Change your code to something line this.

    var products = (from p in m_dataContext.Table_2s
                                    select p.itemid);
                    foreach (var v in products)
                    {
                    }
    

    That should resolve all the Guid related errors .  Hope it helps.

    Wednesday, May 09, 2012 5:13 AM
  • Really sorry Phani,I'm not sure what should come inside for loop should I do the collection.Add method or whatz the format of creating facets.

    Wednesday, May 09, 2012 5:23 AM
  • Should I do something like this.

    for(int iv =0; iv<tempdata.Length;iv++) 

    {

    Facet stringFacet = new Facet("ItemName", FacetType.Text, );

    }
    Wednesday, May 09, 2012 5:29 AM
  • Hi vidhya,

       Once you enter the loop ,  it means that you are dealing with a specific item guid. 

       So you need to get all the products details mapped to that item guid .   So get those details using a linq query and try to create facets. 

      In other words, inside the loop , item id is 1 , and you need to get the various product id's  007,678,004,689

     

    itemid    Productid

    1               007

    1               678

    1               004

    1               689

    2               485

    2               758

    2               756

    So i used that inner loop in my post  to iterate through the values .   The data you want to display  can be put into the facet collection . The facetCollection is an array of facets, as i mentioned previously in my code.  Please see that and try .

    Hope it Helps Laughing 

    Wednesday, May 09, 2012 6:09 AM
  • Thanks for your valuable help.I really appreciate for coming forward to help me.

    Wednesday, May 09, 2012 6:13 AM
  • Hi Phani,

        Sorry to disturb you again.I'm having hard time in creating facet b'coz it throws error.Do u need my addcollection to be within the for loop or creating facet like 

    Facet resourcename = new Facet("Names", FacetType.Text, name);

      FAcet description = new facet("description", facettype.text,description);

    facet uploaddate = new facet("uploaddate",Facettype.text, uploadate);

    It's really confusing.If you don't mind could you please help me fix this.

    Tuesday, May 15, 2012 11:17 PM
  • Hi Vidya,

      i took a facet array fct.    This is my sample array .

     Facet [] fct = new Facet[3];  // I took 3, you can set it dynamically.

      fct[0] = new Facet("FileId", product.artifactid);
      fct[1] =  new Facet("FileName", product.ArtifactName );
      fct[2] =  new Facet("Type", product.Type);
     

    You can add this array to the collection without using a loop.  

    Hope it Helps Laughing

    Wednesday, May 16, 2012 1:51 AM
  • Hi Phani,

     Can you please look into my code below and see if it's right approach.

    Collection collection = new Collection(); 
    collection.Name = "Items"; 
     
       
     try
    {
    var Item = (from p in m_dataContext.item_table select p.itemId). 
    
     
     
     
      foreach (var v in item)  
      {  
         var vals = from p in m_dataContext.item _table where p.Sno == i select p; 
        
         item _table[] tempdata = vals.ToArray<item _table>(); 
     
         Facet[] ftemp= new Facet[tempdata.Length]; 
          
         ItemImage image = null;  
               
    
         ftemp[0] = new facet("ITemid",item.itemid);
         ftemp[1] = new facet("ItemName",item.itemname);
         ftemp[2] = new facet("Description",item.description);
        string image= new ItemImage(new Uri(user.location));
    
     collection.AddItem(ftemp[0],ftemp[1],ftemp[2],ftemp[3],
                           image
                            );
    
    
       return collection;
                }
                catch (Exception ex)
                {
    
                    return ErrorCollection.FromException(ex);
                }
            } 
       
     

        

    Wednesday, May 16, 2012 4:57 AM
  • Hi Vidhya,

       Oh i see.   You dont need to add facets to the collection that way.  The signature of the method is

       collection.AddItem(string name,string url,string description,ItemImage image,Facet []  Array);.

      So change your code to      collection.AddItem(p.Property1, p.property2, p.property3, image, ftemp );

      If you dont have properties, just set them to "" , but if you want ot give name, url , description, then fill those fields. If you dont have an image, you can set it to null

    Hope it Helps Laughing

    Wednesday, May 16, 2012 5:10 AM
  • Is the below code ok now.I need this to bring one image in my pivot b'coz as of now my pivot is showing one image multiple times since my itemid is tied to multiple views.Just want to remind you.If anthing should be added to my code please do let me know b'coz I'm stuck in this for a long time.Your help is much appreciated.

     foreach (var v in item)  
      {  
         var vals = from p in m_dataContext.item _table where p.Sno == i select p; 
        
         item _table[] tempdata = vals.ToArray<item _table>(); 
     
         Facet[] ftemp= new Facet[tempdata.Length]; 
          
         ItemImage image = null;  
               
    
         
      
     collection.AddItem(v.itemid,v.itemname,null,
                        new ItemImage(new Uri(v.location)),
         ftemp[0] = new facet("ITemid",v.viewname);
         ftemp[1] = new facet("ItemName",v.uploaddate);
         ftemp[2] = new facet("Description",v.description);
                           );
    
    
       return collection;
                }
                catch (Exception ex)
                {
    
                    return ErrorCollection.FromException(ex);
                }
            } 
       
    Wednesday, May 16, 2012 5:57 AM
  • 
    
    Hey Phani,

    I need your expert advice.
    I guess i'm almost there I can use my guid in my code but on declaring facet I'm not abel to refer
     it to my database filedname inside the forloop.Please check my code and just help me figure out where I'm wrong.
    If I change the looping constraints i can see all my images doubled to the actual count of image.


    public override Collection MakeCollection(CollectionRequestContext context)
            {
                ItemsDataContext datacontext = new ItemsDataContext();
                 
                try 
                 { 
                   var items = from r in datacontext.ItemTable_s select r.ItemID;
                     Collection collection = new Collection();
                    collection.Name = "ItemCollection";
     
                    Guid[] itemid = items.ToArray<Guid>();
             
               foreach( Guid  i in itemid)  
               {           
                    
                       
       var vals = from r in datacontext.ItemTable_s where r.itemID == i select r;
         
      ItemTable_s[] tempdata = vals.ToArray<.ItemTable_s>();       
         
       Facet[] ftemp= new Facet[tempdata.Length]; 
     
           ItemImage image = null;
    
                for (int iv = 0; iv < tempdata.Length; iv++)
                  {
                  
             ftemp[0] = new Facet("Summary", FacetType.Text,--------- .Description); 
    ftemp[1] = new Facet("Chronological", FacetType.Text,--------.date); 
     ftemp[2] = new Facet("Perspectives", FacetType.Text,--------.Name);               
    
              }
    
                      
                  collection.AddItem( ------.ItemName, null, null, new ItemImage(new Uri(-------.location)),  
                              ftemp[0], ftemp[1], ftemp[2]);
    
                    
                       
    
                                    
           }
                return collection;
                }
                catch (Exception ex) 
                { 
     
                    return ErrorCollection.FromException(ex); 
                } 
            }
    
    Thursday, May 17, 2012 3:46 PM
  • Hi Vidhya ,

       There is one question i want to ask .   Lets say  you have 5 items that belong to one group.  i.e , one image should be displayed for these 5 items.    How do you want the details of these items to be displayed ? Do you want to append all 5 Summaries one after the other  and dispaly in the face collection 

    ftemp[0] =  new Facet("Summary", FacetType.Text,tempdata[i].Description);  will give you description of individual item.     But since that is in a loop , each time it will be overwritten .

    In case you want to append all descriptions of items one after the other , then  you have to do this...

    string s1="";

    for (int iv = 0; iv < tempdata.Length; iv++)
                  {

                  s1 += tempdata[i].Description +" \n";

                  }

    And then ,
    ftemp[0] = new Facet("Summary", FacetType.Text,s1); 

    Hope it Helps Laughing

    Friday, May 18, 2012 12:01 AM
  • Hi Phani,

          Thank you so much for the response.I've one description for one item but that item is associated to 1 or more products which holds itemid as foreign key.Likewise I've 6-7 child tables with item table as parenttable.So in order to grab all the datas from the table,I've created a View. What I need is I need to display one image for each item but still show all the productsname associated to that item and other datas like description,date etc.

     I just need to get my description,date,itemname,image to be displayed once and show all the productname associated to that item.

        Sorry for troubling you.

    Friday, May 18, 2012 12:14 AM
  • Hi Vidhya,

       No troubles  :)  I am here to help and learn.   

         Ok. In that case,  you can change my earlier post to

          ftemp[0] = new Facet("Summary", FacetType.Text,tempdata[i] .Description);

          ftemp[1] = new Facet("Chronological", FacetType.Text,tempdata[i].date);  

              for (int iv = 0; iv < tempdata.Length; iv++)
                   {

                    s1 += tempdata[i].Name  +" \n";  // i think this name contains the product name

                  }

         ftemp[2] = new Facet("Perspectives", FacetType.Text, s1);  // This contains all the product names

        All properties that should appear only once are outside the loop, all the group data should be inside the loop.

    Hope it Helps Laughing

    Friday, May 18, 2012 1:15 AM
  • hi  Phani,

    want to keep you updated,since I'm using GUID datatype I could't use them as tempdata[i] since it's expecting an integer .it throws an error msg saying "cannot implicitly convert type system.GUID to integer" .So i tried using Dictionary instead of array as in my code below but now getting error msg as "an item of the same key value has already been assigned" .I've tried different approachs but this error still keeps appearing in my pivotviewer.Any suggestion?

    var resources = from r in datacontext.item_tables's
                                     select r.itemID; 
                                  
                     Collection collection = new Collection(); 
                    collection.Name = "Items"; 
      
                Guid[] ar= resources.ToArray<Guid>(); 
                foreach (Guid i in ar) 
                                  { 
     
     
                       var prod = (from r in datacontext.item_tables's where r.itemID == i select r); 
                Dictionary<Guid, item_tables> tempdata =prod.ToDictionary(s => s.itemID); 
                 Facet[] ftemp = new Facet[tempdata.Count]; 
                       string s1 = ""; 
                       
                       ftemp[0] = new Facet("descriptiob", FacetType.Text, tempdata[i].Description); 
     
                       ftemp[1] = new Facet("date", FacetType.Text, tempdata[i].uploaddate); 
     
                       
                       for (int iv = 0; iv < tempdata.Count; iv++) 
                       { 
     
                           
                           s1 += tempdata[i].ProductName + " \n";  
                       } 
     
                       ftemp[2] = new Facet("ProductName", FacetType.Text, s1); 
     
                       collection.AddItem(tempdata[i].ItemName, null, null, 
                                
                                     ftemp[0], ftemp[1], ftemp[2] 
                                     ); 
                   }
    Sunday, May 20, 2012 8:49 PM
  • Hi Vidhya,

    This was your earlier code  

       var vals = from r in datacontext.ItemTable_s where r.itemID == i select r;
         
     
    ItemTable_s[] tempdata = vals.ToArray<.ItemTable_s>();

    vals contains the item , right.  Not just the guid.  So Tempdata should also contain the entire item.

    The real error in my code is the loop variable.  I used iv for the for loop,  but i wrote tempData[i].    Since i is Guid, it was throwing error.  So all that logic is correct , except the loop variable part.

    Also , when you are adding items to the collection, do it in a separate for loop .

    Hope it Helps Laughing

    Sunday, May 20, 2012 9:42 PM
  • Hi Phani,

            I understand the variable in Forloop which is declared as iv but the facet[0],facet[1] is declared prior to the forloop where i declare as

    var resources = from r in datacontext.item_tables's 
                foreach (Guid i in ar) 
                                  { 
     
     
                       var prod = (from r in datacontext.item_tables'
    s where r.itemID == i select r); 

     ItemTable_s[] tempdata = vals.ToArray<.ItemTable_s>();
               
                 Facet[] ftemp = new Facet[tempdata.Count]; 
                      
    string s1 = ""; 
                       
                       ftemp
    [0] = new Facet("descriptiob", FacetType.Text, tempdata[i].Description); 
     
                       ftemp
    [1] = new Facet("date", FacetType.Text, tempdata[i].uploaddate); 
     
                       
                      
    for (int iv = 0; iv < tempdata.Count; iv++) 
                      
    { 
     
                           
                           s1
    += tempdata[iv].ProductName + " \n";  
                      
    } 
     
                       ftemp
    [2] = new Facet("ProductName", FacetType.Text, s1); 
     
                       collection
    .AddItem(tempdata[i].ItemName, null, null, 
                                
                                     ftemp
    [0], ftemp[1], ftemp[2] 
                                    
    ); 
                  
    }

     

                    

    Sunday, May 20, 2012 10:09 PM
  • Hi ,

      Take a global count variable. It should keep track of that tempdata index . :)

     

                      var resources = from r in datacontext.item_tables 
                                      select r.itemID;  
                                   
                      Collection collection = new Collection();  
                      collection.Name = "Items";  
       
                      Guid[] ar= resources.ToArray<Guid>();  
    
    
                      int count=0;   //  This should solve it ,  or you can place those ftemp[0] ,ftemp[1] inside the loop 
    
                      foreach (Guid i in ar)  
              
                      {  
        
                       var prod = (from r in datacontext.item_tables  where r.itemID == i select r);  
                      
                       Dictionary<Guid, item_tables> tempdata =prod.ToDictionary(s => s.itemID);  
              
                       Facet[] ftemp = new Facet[tempdata.Count];  
                    
                       string s1 = "";  
                        
                       ftemp[0] = new Facet("descriptiob", FacetType.Text, tempdata[count].Description);  
      
                       ftemp[1] = new Facet("date", FacetType.Text, tempdata[count].uploaddate);  
      
                        
                       for (int iv = 0; iv < tempdata.Count; iv++)  
                       {  
       
                           s1 += tempdata[iv].ProductName + " \n";   
                       }  
      
                       ftemp[2] = new Facet("ProductName", FacetType.Text, s1);  
      
                       collection.AddItem(tempdata[count].ItemName, null, null,  
                                 
                                     ftemp[0], ftemp[1], ftemp[2] );  
                       
                       count ++ ;
                     
                       }

    Hope it HelpsLaughing

    Sunday, May 20, 2012 11:48 PM
  • Hi Phani,

            I think you can only help me on this issue as you have been helping me on this scenario and after a long try I'm back here for your help which I'm facing now as I tried to do a debugging and it appears to be some looping issue.It throws error message 

    "Index was outside the bounds of the array" error.

    I tried to do a debug and found out that when my integer count variable x reaches value 4 it breaks and throws this error.for example if i have 2 rows for one itemid the value of x = 0 for the first row and on looping again the value is X=1 on my second row,similarly I had 4 rows for my next itemid and on looping it was returning x=2 on my 1st row and x=3 on my second row and then breaksup and throws this error on my pivot. I tried to put the facets inside the forloop but no luck it's keep showing the same error.Any suggestioons or reason Y i'm getting this error is much apreciated.

        

    Tuesday, May 22, 2012 4:55 PM
  • Hi Vidhya, 

         It means you have to reset the x value before it starts processing the second row.  So in the last statement of the loop (where you are going to process the next row), write x=0;  This will solve your out of bounds issue.

    Hope it Helps Laughing

    Tuesday, May 22, 2012 8:32 PM
  • Hi Phani,

         I'm really sorry to  disturb and holding you with this issue for a long time. It's really giving me a hardtime.I did a reset x=0 as you suggested before the next record is read.But no luck.I'll explain what I did even after adding x=0 i still received the error index outside bound.Then i changed the forloop like

    for (iv=0;iv < tempdata[length]+1,iv++) and declaring x=0 together helped me get rid of that error but still shows multiple images.I tried to debug and I found out that on the foreach loop it grabs my first itemid (datas appear like below eg) and enter the forloop and gets all the productid associated to that itemid and does the collection again it refers the same itemid and does the same functionality as per the count of each itemid.In my below eg case it runs through the loop 4 times doing the same functionality.Please help..

    itemid    productid

     1             789

     1             900

     1             646

     1             134

    Wednesday, May 23, 2012 10:41 PM
  • Hi Phani,

             Found the solution.This info might help you.I replaced my below code

    var resources = from r in datacontext.item_tables

                                      select r.itemID;

    var resources = (from r in datacontext.item_tables

                                      select r.itemID).Distinct();

    that removed the selection of itemid several times to once.But still was showing "Index ouside bounds error" I fixed it by replacing my forloop  to

     for (int iv = 0; iv <=(tempdata.Length-1); iv++)

    {

        s1 += tempdata[iv].ProductName + "/";

     

    }

    and now my index error on forloop was solved and started showing "Index outside bounds" error in facet declaration, I changed facet array as

         Facet[] ftemp = new Facet[5];

    as i had ftemp[0],ftemp[1],ftemp[2],ftemp[3],ftemp[4].

    That it all my error solved and got one image in my pivot.

    Thank you so much Phani for your wonderfull help and valuable suggestions.

    
    
    
    
    
    
    
    

                                                    

     

    Friday, May 25, 2012 11:55 AM
  • Hi Phani,

             Found the solution.This info might help you.I replaced my below code

    var resources = from r in datacontext.item_tables

                                      select r.itemID;

    var resources = (from r in datacontext.item_tables

                                      select r.itemID).Distinct();

    that removed the selection of itemid several times to once.But still was showing "Index ouside bounds error" I fixed it by replacing my forloop  to

     for (int iv = 0; iv <=(tempdata.Length-1); iv++)

    {

        s1 += tempdata[iv].ProductName + "/";

     

    }

    and now my index error on forloop was solved and started showing "Index outside bounds" error in facet declaration, I changed facet array as

         Facet[] ftemp = new Facet[5];

    as i had ftemp[0],ftemp[1],ftemp[2],ftemp[3],ftemp[4].

    That it all my error solved and got one image in my pivot.

    Thank you so much Phani for your wonderfull help and valuable suggestions.

    Friday, May 25, 2012 11:58 AM