I would like my grid view to display only 3 rows any ideas on how I can achieve this?
Thanks
I would like my grid view to display only 3 rows any ideas on how I can achieve this?
Thanks
Enable Paging and set the GridView's PageSize
to 3.
How to: Enable Default Paging in the GridView Web Server Control
If you want to restrict your GridView to show only 3 rows without paging, you need to use a DataSource
with only 3 records (f.e. via SQL-TOP
-Clause or Limit
in MySQL or LINQ's Take(3)
).
AllowPaging="true"
and `AllowSorting="true"`` on my GridView. Thanks a bunch :) –
Oh If you can limit the records in your query, then that's the best approach.
However, if you can't limit them in the query... here is another approach:
allowpaging=true
" and "pagesize=X
" (change X to how many rows you want visible).Assign a pagerstyle with a custom CSS class.
<pagerstyle cssclass="hidden" />
Set that custom class to:
.hidden { visibility: hidden; display: none; }
Now, your grid will use the paging logic, but the pager controls are hidden.
It's not the cleanest/most elegant, but it works.
I'd keep it simple and ensure your DataSource only provides the three rows of data you need to display.
Failing that, you could set the .Visible
property of all Rows
to false
, except Rows[0]
through Rows[2]
.
2 ways that i can think of.....
OR
Use paging!!!!!!
go to view and click on grid and a small overlay opens allowing (requiring you) to enter a number for the column. then preview and click save
you can use Repeater instead as follow.
<asp:Repeater ID="Repeater2" runat="server" >
<HeaderTemplate>
<table class="center">
<tr>
<%#If((Container.ItemIndex <> 0 AndAlso Container.ItemIndex Mod 4 = 0), " ", String.Empty)%>
' PostBackUrl='<%# Container.DataItem("url")%>' >
</asp:Repeater>
© 2022 - 2024 — McMap. All rights reserved.