on 06-19-2006 10:53 PM
I've been working with the PDK for .NET 2.5 on Visual Studio 2005, and I recently discovered an anomaly with the SAP Table control. It appears that the table will not render properly if it is bound to an empty result set after it was bound to a result set with 4 or more records. If you bind to a result set with 5 records, and then to a result set with 0 records on a page reload, then the records 4 and 5 from the previous result set will be in the new table (that should have 0 records).
I created a sample portal component (below) for you to test out. To replicate this behavior:
- Build and deploy the portal component with the code below.
- Enter 5 in the textbox to populate the table with 5 records.
- Click the "Get Result Set" button.
- Enter 0 in the textbox to populate the table with 0 records.
- Click the "Get Result Set" button.
- There should now be 2 records in table.
Can anybody provide any insight into this anomaly, or confirm if it is a bug? Are there any recommendations on how to fix or work around this?
- Lenny
(Using SAP PDK for .NET 2.5 on EP6 SP16, Version 6 Support pack 16)
-
Begin Code -
<!-- TableResidueTest.ascx -->
<!%@ PortalComponent name="TableResidueTest" %>
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="TableResidueTest.ascx.cs" Inherits="BadTable.TableResidueTest" %>
<%@ Register Assembly="SAP.Web, Version=1.2.0.0, Culture=neutral, PublicKeyToken=50436dca5c7f7d23" Namespace="SAP.Web.UI.Controls" TagPrefix="sap" %>
<link href="C:\Program Files\SAP\Portal Add-in for Visual Studio 2005\Controls\ur\ur_design.css" type="text/css" rel="stylesheet"/>
<body class="prtlBody">
<sap:Table ID="Table1" runat="server">
<sap:TableRow runat="server" ID="Table1_ItemTemplate">
<sap:TableCell runat="server" ID="Table1_Name" Title="Name"><sap:TextView runat="server" ID="Table1_Name_TextView1" Text='<%# DataBinder.Eval(Container.Parent, "DataSourceRow.DataItem.Name") %>'></sap:TextView>
</sap:TableCell>
<sap:TableCell runat="server" ID="Table1_PhoneNumber" Title="PhoneNumber"><sap:TextView runat="server" ID="Table1_PhoneNumber_TextView1" Text='<%# DataBinder.Eval(Container.Parent, "DataSourceRow.DataItem.PhoneNumber") %>'></sap:TextView>
</sap:TableCell>
</sap:TableRow>
<sap:Caption runat="server" Text="Table" ID="Table1_Caption1"></sap:Caption>
</sap:Table>
Record count <sap:InputField ID="txtRecordCount" runat="server"></sap:InputField>
<sap:Button ID="btnGetResultSet" runat="server"
Text="Get Result Set" OnAction="btnGetResultSet_Action"></sap:Button> <br />
</body>
//////////////////////////////////////////////////////
// TableResidueTest.ascx.cs
//////////////////////////////////////////////////////
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using SAP.Portal.Web.UI;
using SAP.UI;
using SAP.Web.UI.Controls;
using System.ComponentModel;
using System.Collections.Generic;
namespace BadTable
{
public partial class TableResidueTest : SAP.Portal.Web.UI.PortalComponent
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnGetResultSet_Action(object sender, AbstractButton.ActionEventArgs e)
{
Table1.DataSource = BusinessObject.GetRecords(txtRecordCount.Value);
Table1.DataBind();
}
}
public static class BusinessObject
{
public static List<DataObject> GetRecords(string count)
{
int recordCount = 0;
int.TryParse(count, out recordCount);
List<DataObject> records = new List<DataObject>();
for (int i = 0; i < recordCount; i++)
{
records.Add(new DataObject("John Doe", i.ToString()));
}
return records;
}
}
public class DataObject
{
private string name;
public string Name
{
get { return name; }
set { name = value; }
}
private string phoneNumber;
public string PhoneNumber
{
get { return phoneNumber; }
set { phoneNumber = value; }
}
public DataObject(string name, string phoneNumber)
{
this.name = name;
this.phoneNumber = phoneNumber;
}
}
}
//////////////////////////////////////////////////////
// TableResidueTest.ascx.designer.cs
//////////////////////////////////////////////////////
namespace BadTable {
public partial class TableResidueTest {
protected SAP.Web.UI.Controls.Table Table1;
protected SAP.Web.UI.Controls.TableRow Table1_ItemTemplate;
protected SAP.Web.UI.Controls.TableCell Table1_Name;
protected SAP.Web.UI.Controls.TextView Table1_Name_TextView1;
protected SAP.Web.UI.Controls.TableCell Table1_PhoneNumber;
protected SAP.Web.UI.Controls.TextView Table1_PhoneNumber_TextView1;
protected SAP.Web.UI.Controls.Caption Table1_Caption1;
protected SAP.Web.UI.Controls.InputField txtRecordCount;
protected SAP.Web.UI.Controls.Button btnGetResultSet;
}
}
Hi Lenny,
I believe that using Table1.FillUpEmptyRows = false may workaround this issue.
Regards,
Rima.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.