Hi I am working on a page which requires the grid to be populated with 'n' number of rows, as the user enters the number 'n' in a text box.

Can anyone help me out in this?

Use

for (int i = 0; i < n; i++)
{
      dataGridview.Rows.Add();
}

to add n rows to your DataGridView

Did you mean DataGridView in C# windows based applications or GridView in ASP.NET ?

Grid view in asp.net

Basically you will have to create a DataTable, and work on that. The datatable would have the same columns as your grid view. you can add new rows, and data accordingly to this DataTable, and finally you will have to set the datasource for the gridView as this datatable you have created.

Have a read through this article:

http://www.victorchen.info/add-rows-to-a-datatable-in-c/

thanks a lot.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.