Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have created a custom WebPart to consume connection(table) from a list view webpart, from list view webpart when i send the table to my custom consumer webpart i get all data from the list, but this works fine only when number of records is less than the page limit of the list view, suppose I have 100 data and list view page limit is only 30, then there are total 4 pages in the list view but when i send the data to my custom consumer webpart I get only first page data. And also if i filter the list view, the filtered value is not reflected in my consumer it still shows the same static first page data. How to overcome this problem?


Here is the code that I used

public class TableConsumer : WebPart
{
private IWebPartTable _provider;
private ICollection _tableData;

private void GetTableData(object tableData)
{
  _tableData = (ICollection)tableData;
}

protected override void OnPreRender(EventArgs e)
{
  if (_provider != null)
  {
    _provider.GetTableData(new TableCallback(GetTableData));
  }
}

protected override void RenderContents(HtmlTextWriter writer)
{
  if (_provider != null)
  {
    PropertyDescriptorCollection props = _provider.Schema;
    int count = 0;
    if (props != null && props.Count > 0 && _tableData != null)
    {
      foreach (PropertyDescriptor prop in props)
      {
        foreach (DataRow o in _tableData)
        {
          writer.Write(prop.DisplayName + ": " + o[count]);
        }
        writer.WriteBreak();
        writer.WriteLine();
        count = count + 1;
      }
    }
    else
    {
      writer.Write("No data");
    }
  }
  else
  {
    writer.Write("Not connected");
  }
}

[ConnectionConsumer("Table")]
public void SetConnectionInterface(IWebPartTable provider)
{
  _provider = provider;
}
}
share|improve this question
    
can you add some code where your trying to get connection/table data –  Muhammad Raja Nov 15 '12 at 8:15
    
I used the sample code described here msdn.microsoft.com/en-us/library/… –  Diptarag Nov 15 '12 at 8:18
    
Could you just not make a different list view that doesn't have the limitation on page size, just for this purpose? –  Hugh Wood Nov 22 '12 at 12:33
    
For some reason I can not :) one of many reason is i am making a generic webpart which should work for all list view webpart –  Diptarag Nov 22 '12 at 12:42
    
Another thing I should add I already solved the problem with a not-so-elegant approach of not using web part connection, that's trivial, but I want to know why webpart connection behaving like this –  Diptarag Nov 22 '12 at 12:45
add comment

1 Answer 1

I would need to see your code to know whats going on, but looking form the example can you change:

public void GetTableData(TableCallback callback)
{
    callback(_table.Rows);
}

to

public void GetTableData(TableCallback callback)
{
    callback(_table);
}

the issue is in the provider class that is sending the data to the consumer class. The I think thats what you need? if not then i would need to do it myself and test to see what the results are going into each provider and consumner in debug to know where its going wrong :)

hope it helps :)

share|improve this answer
    
Hi as I mentioned in my post I made the consumer portion myself, but the provider web part in this case is sharepoint default list view webpart, you pointed out a change for provider portion which I am not creating in my case, anyway appreciate your help –  Diptarag Nov 15 '12 at 9:15
    
yup i understand that, what im getting to is have you debugged your code? do you know what is going into your consumer class? do you know what is being sent by the provider class. Without your code poseted here how would i know what part is causing you to only see page by page. If your sending the full datatable then its somthing wrong with the consumer class and not the provider. but i cant help untill you show some code :) untill then everyone will be shooting in the dark ;) –  ali Sharepoint Nov 15 '12 at 9:22
    
I used the Consumer Portion of the code in the link I posted, so i thought i could just give the link, anyway I am posting the code then. –  Diptarag Nov 15 '12 at 9:26
    
after looking through the code I couldnt see anything wrong! have you debugged your code to see the value thats goin into the datatable? If its got the full values (full 100 recoreds or only 30)? if it has 30 then its 100% provider and if it does have 100 the its 100% consumer problem! btw it looks like this ;) msdn.microsoft.com/en-us/library/… –  ali Sharepoint Nov 15 '12 at 9:57
    
ya i debugged the code, it's getting only 30 records (page size) and the provider part I dont have access as it is list view webpart :P and of course the code looks like the link you posted, because it is the same link that i posted initially, that's why i dint post the code in first place, so i guess i need to take some other way than web part connection –  Diptarag Nov 15 '12 at 10:05
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.