Number of Rows to display

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
zachvaldezAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
sonawanekiranConnect With a Mentor Commented:
0
 
sonawanekiranConnect With a Mentor Commented:
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
 
sonawanekiranConnect With a Mentor Commented:
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
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
zachvaldezAuthor Commented:
How you handle dropdowlist that are prepopulated.
0
 
zachvaldezAuthor Commented:
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
 
CodeCruiserCommented:
>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
 
zachvaldezAuthor Commented:
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
 
CodeCruiserCommented:
As I said in other question, I am not aware of a way of adding empty rows in gridview directly.
0
 
zachvaldezAuthor Commented:
So can't do something like
Grdview2.(cell,row)
= textbox1.text..not exactly correct syntax
0
 
CodeCruiserCommented:
Not if the cell at the row and column does not exist already.
0
 
zachvaldezAuthor Commented:
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
 
zachvaldezAuthor Commented:
I saw someone use the
'Empty Data 'Template and even
Added Insert,Delete capabilities but I'll have to check it out.Interesting.
0
 
CodeCruiserCommented:
What are you trying to achieve, can you show us a screenshot?
0
All Courses

From novice to tech pro — start learning today.