You must Sign In to post a response.
  • Category: .NET

    How to set only 10 rows per datagridview in .net winforms

    How to set only 10 rows per datagridview in .net winforms
  • #619402
    Hi,

    Try the folloeing code



    <asp:gridview id="Employee"
    allowpaging="true"
    pagesize="15"
    runat="server">
    </asp:gridview>


    Cheers!!!!

    Rajesh Kumar Parbat
    (Mentor,Editor,MVM)

  • #619412
    asp.net its ok
    I am asking Windows Application

  • #619453
    We have to use PageSize property for Windows application also.

    customDataGrid1.PageSize = 10; customDataGrid1.DataSource = data; customDataGrid1.BindGrid();

  • #619463
    Hi Saravanan,

    You are right that we dont have inbuild functionality for the pagesize in windows application.
    for this we need to write our own custom code which will do tht navigation based on our requirements.
    so the first tig is we need to declare the pagesie variable and how many records we want in a page e.g. 10
    Then we need to create a fucntion which will take these two as parameter and based on these parameter it will fetch the records from the database.

    For the full code refernce follwo the below post which already explain about this:

    http://www.dotnetspider.com/resources/38423-Paging-for-DataGridView-Control.aspx

    Regards,
    Pawan Awasthi(DNS MVM)
    +91 8123489140 (whatsApp), +60 14365 1476(Malaysia)
    pawansoftit@gmail.com

  • #619491
    Hi check this

    private void Dgv_display()
    {
    try
    {
    dataGridView1.Rows.Add(10);
    dataGridView1.AllowUserToAddRows = false;
    dataGridView1.AllowUserToDeleteRows = false;
    }
    catch (Exception ex)
    {
    MessageBox.Show(ex.Message.ToString());
    }

    }


  • This thread is locked for new responses. Please post your comments and questions as a separate thread.
    If required, refer to the URL of this page in your new post.