• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 220
  • Last Modified:


can somebody tell me how to dynamically change the number of rows in a datagrid based on a value entered by the user
thank you in advance
2 Solutions
Take the user's Input and go through the data set that many amout of times and copy the values one by one that you want to enter ! Hope that helps sorry I can not be more presice !
Good Luck . FuLP
Hi yalamanchir,

What do you mean exactly by "change the number of rows" ?

Is it paging problem ?
If so, modify the datagrid page size with the user value and (re)bind datas.

Or a data problem ?
Then , when you (re)bind datas, modify the filter of your dataview considering the user value.

Hope this will help you.
yalamanchirAuthor Commented:
i want to have textbox for the users to enter a number... and if they enter 10
i want to populate that many rows in my datagrid
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

You set the datasource to a table perhaps, right?

then you should add rows the the underlying datatable, and that will "add" rows to the datagrid.

public function addrows(numrows as integer)

        Dim table As DataTable = CType(DataGrid1.DataSource, DataTable)
        For i As Integer = 1 To numrows
            Dim row As DataRow = table.NewRow
        Next i
    End Sub
You can not change the Number of Rows in the DataGrid directly.
The Datagrid shows the number of rows based on the underlying dataTable
So in case you want to modify the Number of Rows you'll have to modify the Number of rows in the Underlying Table

You will need to update your sql to pull just the number of records you want ie
"SELECT TOP " & CInt(TextEntry.Text) & " * FROM tblCustomer WHERE ......... "
Dont forget to rebind your datagrid to update the changes
What's up with the C?

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now