Solved

Number of Rows to display

Posted on 2011-09-29
13
269 Views
Last Modified: 2012-05-12
Is it possible to control the number of Gridview or table rows ?
I have an input textbox which I would type a number. for example if I type 5, the Gridview would adjust and dynamically display 5 rows.

In the Gridview, I have added itememplatefield and d placed textboxes and dropdowns in several cells on same row. Is it possible add  the number ROW with the predesigned controls in teh cells display\ too
when the appropraite number rows are defined in the textbox
0
Comment
Question by:zachvaldez
  • 6
  • 4
  • 3
13 Comments
 
LVL 17

Assisted Solution

by:sonawanekiran
sonawanekiran earned 250 total points
ID: 36886879
Yes it is possible.
1) Add onchange event to textbox and autopostback property to true like
 <asp:TextBox
        id="txtSearch"
        AutoPostBack="true"
        OnTextChanged="txtSearch_TextChanged"
        Runat="server" />

2) In txtSearch_TextChanged event

 protected void txtSearch_TextChanged(object sender, EventArgs e)
    {
       gv1.PageSize= e.NewPageSize;
       gv1.PageIndex = 0;
       // Add code to bind grid e.g gv1.DataSouce = ..; and gv1.DataBind();
    }
 
0
 
LVL 17

Accepted Solution

by:
sonawanekiran earned 250 total points
ID: 36887346
0
 
LVL 17

Assisted Solution

by:sonawanekiran
sonawanekiran earned 250 total points
ID: 36888287
Some modification in above code

protected void txtSize_TextChanged(object sender, EventArgs e)
    {
       gv1.PageSize= Convert.toString(txtSize.Text); // Size from your textbox
       gv1.PageIndex = 0;
       // Add code to bind grid e.g gv1.DataSouce = ..; and gv1.DataBind();
    }
0
ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

 

Author Comment

by:zachvaldez
ID: 36889947
How you handle dropdowlist that are prepopulated.
0
 

Author Comment

by:zachvaldez
ID: 36901338
What I mean here is that I have a textbox where I can input a number. That number will determine the number of Gridview rows which is produce when a buton is clicked.
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 36906177
>That number will determine the number of Gridview rows which is produce when a buton is clicked.

Is that the number of rows in a page or the number of empty rows added to the grid?
0
 

Author Comment

by:zachvaldez
ID: 36906259
Empty rows. The point and I know u have ideas is to limit and exact the rows for data entry and not exceed it. For ex.
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 36906360
As I said in other question, I am not aware of a way of adding empty rows in gridview directly.
0
 

Author Comment

by:zachvaldez
ID: 36906556
So can't do something like
Grdview2.(cell,row)
= textbox1.text..not exactly correct syntax
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 36906710
Not if the cell at the row and column does not exist already.
0
 

Author Comment

by:zachvaldez
ID: 36907034
How about if you have textboxes inside the Griview's cells?
Is it not possible to find the control and assigned the textbox for firstname... textbox  then then column textbox ... for lastname textbox.. something like that> What requirnments needed for that to happen?
0
 

Author Comment

by:zachvaldez
ID: 36909468
I saw someone use the
'Empty Data 'Template and even
Added Insert,Delete capabilities but I'll have to check it out.Interesting.
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 36912253
What are you trying to achieve, can you show us a screenshot?
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

773 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