Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 288
  • Last Modified:

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
0
zachvaldez
Asked:
zachvaldez
  • 6
  • 4
  • 3
3 Solutions
 
sonawanekiranCommented:
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
 
sonawanekiranCommented:
0
 
sonawanekiranCommented:
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 6
  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now