Solved

datatgrid

Posted on 2004-10-04
7
193 Views
Last Modified: 2010-05-19
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
0
Comment
Question by:yalamanchir
7 Comments
 
LVL 2

Expert Comment

by:fulp02
ID: 12221931
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
0
 
LVL 9

Expert Comment

by:noulouk
ID: 12221967
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.
Regards.
0
 

Author Comment

by:yalamanchir
ID: 12222178
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
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
LVL 8

Accepted Solution

by:
gregasm earned 200 total points
ID: 12223541
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
            table.Rows.Add(row)
        Next i
    End Sub
0
 
LVL 19

Assisted Solution

by:arif_eqbal
arif_eqbal earned 300 total points
ID: 12224086
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

0
 
LVL 6

Expert Comment

by:PreachDotNet
ID: 12227896
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
0
 
LVL 8

Expert Comment

by:gregasm
ID: 12303433
What's up with the C?
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question