Solved

Number of Rows to display

Posted on 2011-09-29
13
266 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
 

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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

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 …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

706 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now