Solved

Number of Rows to display

Posted on 2011-09-29
13
273 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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

Suggested Solutions

Title # Comments Views Activity
Visual studio 2015 1 22
VB.net Open video relating to control 2 20
Can Angular be used with classic asp.net? 3 19
VB.NET Inline If statement 4 18
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

828 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