Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
I have a table called A with 15 rows. I have used paging concept to display only 5 rows at initial load. Once the user clicks on next it will display me another 5 rows. Now Im gonna select any one or two rows and from table 'A' to table 'B'. Now I need to implement the same paging concept in Table B, i.e if the user selects any thing more than 5 rows from table 'A' it should limit the display to 5 rows in table 'B' and user should only be able to view the 6 th row by click on next button.

I have tried with different possible ways but I am failing to achieve it Can any one help me out?

I have placed my code snippet for selecting a row from Table A by selecting a row and displaying it in Table B



private void btnSelect_Click(object sender, EventArgs e)
    {
        DataGridViewSelectedRowCollection selectedRows = dgvFormFieldsView.SelectedRows;
        dgvFormFieldsView.ClearSelection();

          if (selectedRows.Count == 0)
          {
            MessageBox.Show("No rows selected!", "PDF Perform Warning");
            return;
          }
          for (int i = selectedRows.Count - 1; i >= 0; i--)
          {
                string fieldLabel = null;
                string fieldType = null;
                string tabOrder = null;

                tabOrder = (string)selectedRows[i].Cells[0].Value;
                fieldLabel = (string)selectedRows[i].Cells[1].Value;
                fieldType = (string)selectedRows[i].Cells[2].Value;

                DataRow newRow = selectedFieldsTable.NewRow();
                newRow["Field Name"] = fieldLabel;
                newRow["Field Type"] = fieldType;

                if (!selectedFieldsTable.Rows.Contains(new System.Object[] { fieldType, fieldLabel }))
                {
                    selectedFieldsTable.Rows.Add(newRow);

                }
                else
                {
                    MessageBox.Show("Form Field :" + fieldLabel + " already selected", "PDF Perform Info");
                }
            }
            dgvSelectedFieldsView.DataSource = selectedFieldsTable;
            dgvSelectedFieldsView.ClearSelection();
            applyFormattingSelectedFieldsTable();

            foreach (DataGridViewRow row in dgvSelectedFieldsView.Rows)
            {
                row.Cells[2].Style.BackColor = fieldValueDefaultBackColor;
                row.Cells[2].Style.SelectionBackColor = fieldValueSelectionBackColor;
            }
            if (ConfigParams.mode == Mode.Extract || ConfigParams.mode == Mode.Compare)
                dgvSelectedFieldsView.Columns["Field Value"].ReadOnly = true;
    }







Can any one help me out
Thanks
Posted
Updated 27-Feb-13 2:53am
v3
Comments
Jegan Thiyagesan 27-Feb-13 12:32pm    
Hi, I am totally confused with your question and the code block you have posted, Where is the part that restricting the rows when it is more than 5? can you be bit more specific?

Jegan

1 solution

Hi Jagan,
Actually, I couldn't find any solution to restrict the rows to 5
i can only do like statements below.. but i can restrict for 5 but cant accomplish paging concept


C#
if(selectedFieldsTable.Rows.Count < 5)
{
for (int i = selectedRows.Count - 1; i >= 0; i--)
                {

                    string fieldLabel = null;
                    string fieldType = null;
                    string tabOrder = null;

                    tabOrder = (string)selectedRows[i].Cells[0].Value;
                    fieldLabel = (string)selectedRows[i].Cells[1].Value;
                    fieldType = (string)selectedRows[i].Cells[2].Value;

                    DataRow newRow = selectedFieldsTable.NewRow();
                    newRow["Field Name"] = fieldLabel;
                    newRow["Field Type"] = fieldType;


                    if (!selectedFieldsTable.Rows.Contains(new System.Object[] { fieldType, fieldLabel }))
                    {

                        selectedFieldsTable.Rows.Add(newRow);

                    }
                    else
                    {
                        MessageBox.Show("Form Field :" + fieldLabel + " already selected", "PDF Perform Info");
                    }

                }
          }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900