• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 222
  • 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
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

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?
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

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