Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to 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 27-Feb-13 2:18am
Edited 27-Feb-13 2:53am
v3
Comments
Jegan Thiyagesan at 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

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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
 

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");
                    }
 
                }
          }
  Permalink  

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 499
1 Nirav Prabtani 298
2 OriginalGriff 215
3 _Amy 165
4 Abhinav S 160
0 OriginalGriff 7,715
1 Sergey Alexandrovich Kryukov 6,911
2 Maciej Los 3,954
3 Peter Leow 3,698
4 CHill60 2,742


Advertise | Privacy | Mobile
Web02 | 2.8.140721.1 | Last Updated 27 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100