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;
}
}