cancel
Showing results for 
Search instead for 
Did you mean: 

Paging a Table

Former Member
0 Kudos

Could someone help me with the code to maintain the data when paging the table. I populated the table based on the role that the user selected in a drop down. Here is my existing code.

Protected Sub ddkRolesList_Select(ByVal sender As System.Object, ByVal e As SAP.Web.UI.Controls.AbstractDropDownByKey.SelectEventArgs) Handles ddkRolesList.Select

Dim um As New UserManagement

Dim role As String = ddkRolesList.SelectedKey.ToString()

Dim users As Array = um.GetUsersOfRole(role, True)

Dim user As String

For Each user In users

Dim tRow As New TableRow()

Dim tCell As New TableBodyCell()

Dim tCell2 As New TableBodyCell()

Dim tCell3 As New TableBodyCell()

tCell.TableCellContent = New TextView(GetName(user))

tRow.Cells.Add(tCell)

tCell2.TableCellContent = New TextView(GetEmail(user))

tRow.Cells.Add(tCell2)

tCell3.TableCellContent = New CheckBox()

tRow.Cells.Add(tCell3)

Table1.Items.Add(tRow)

Next

End Sub

Thanks,

Gabe Petro

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Amit - I have changed my code a bit. Is it possible for you to help by being specific to my example? I am struggling to find info on using anything but a sqlAdapter call. I am not using sql but instead a query of the UM.

Private Sub BuildTable(ByVal roleID As String)

Dim um As New UserManagement()

Dim role As String = roleID

Dim users As Array = um.GetUsersOfRole(role, True)

Dim user As String

tblRoleA.Header.Text = "Users of " & ddkRoleA.SelectedItem.Text

Dim usersTable As New DataTable

Dim myDataRow As DataRow

Dim myDataView As DataView

usersTable.Columns.Add("Name", Type.GetType("System.String"))

usersTable.Columns.Add("Email", Type.GetType("System.String"))

' Iterate FileInfo objects to populate the DataTable.

For Each user In users

myDataRow = usersTable.NewRow()

myDataRow("Name") = GetUserName(user)

myDataRow("Email") = GetUserEmail(user)

usersTable.Rows.Add(myDataRow)

Next user

' Create a new DataView and sort it based on the sort field.

myDataView = usersTable.DefaultView

'myDataView.Sort = strSortField

tblRoleA.DataSource = myDataView

tblRoleA.DataBind()

End Sub

Former Member
0 Kudos

Hi Gabe,

how are you doing ?

have you informed yourself of the links presented by Ofer in the following thread : ?

that is the methodology to be able to access the UM from within NPDK

comming to the code :

the logical steps in your case

1> read portal object

2> create local copy of data object

3> create local data table

4> create default view and bind grid

they are over engineered, but none the less should yeild the result you require

what result do you get with the code ?

um.GetUsersOfRole(role, True)

please check the methods

1> GetUserName

2> GetUserEmail

as they are outside the scope of the current function

with respect,

amit

-


Private Sub BuildTable(ByVal roleID As String)

Dim um As New UserManagement()

Dim role As String = roleID

Dim users As Array = um.GetUsersOfRole(role, True)

Dim user As String

tblRoleA.Header.Text = "Users of " & ddkRoleA.SelectedItem.Text

Dim usersTable As New DataTable

Dim myDataRow As DataRow

Dim myDataView As DataView

usersTable.Columns.Add("Name", Type.GetType("System.String"))

usersTable.Columns.Add("Email", Type.GetType("System.String"))

' Iterate FileInfo objects to populate the DataTable.

For Each user In users

myDataRow = usersTable.NewRow()

myDataRow("Name") = GetUserName(user)

myDataRow("Email") = GetUserEmail(user)

usersTable.Rows.Add(myDataRow)

Next user

' Create a new DataView and sort it based on the sort field.

myDataView = usersTable.DefaultView

'myDataView.Sort = strSortField

tblRoleA.DataSource = myDataView

tblRoleA.DataBind()

End Sub

Former Member
0 Kudos

I am having no problem accessing the UM and binding the data to the grid. My problem is being able to page through the data. I was looking for an some help on how to use the code I have and add paging functionality. If you can help with that it would be appreciated.

Former Member
0 Kudos

Hi Gabe,

how are you doing ?

Basic steps to enable Paging in a SAP Netweaver Table Control,

you need to :-

1> create a server side event for paging on the table

2> call a binding procedure within the event handler

        • the example is kept simple to demonstrate paging, it is not optimized for performance ****

with respect,

amit

-


protected DataSet dsxBUList;

protected SAP.Web.UI.Controls.Table tblCustList;

-


private void tblCustList_Paging(object sender, SAP.Web.UI.Controls.PagingEventArgs e)

{

pageLoader();

}

private void pageLoader()

{

listBUs();

}

private void listBUs()

{

string strConnection;

// use service user temporarily :

// invoke the BU List web service

wsBusinessPartner wsBUList = new wsBusinessPartner();

dsxBUList = wsBUList.getBUList("",strConnection);

// display the results

if(dsxBUList != null)

{

tblCustList.Visible = true;

bindBUListGrid();

}

else

{

tblCustList.Visible= false;

}

}

private void bindBUListGrid()

{

tblCustList.DataSource = null;

if (dsxBUList!=null)

{

if (dsxBUList.Tables.Count>0)

{

tblCustList.DataSource = dsxBUList.Tables[0];

tblCustList.DataBind();

}

}

}