|
|
Rank: Advanced Member Groups: Member
Joined: 1/31/2008 Posts: 41 Points: 123 Location: India
|
hi
can we restrict max no of rows in gridview control? if yes how we can do that
many thanks
|
|
|
|
|
|
Rank: Advanced Member Groups: Member
Joined: 3/3/2008 Posts: 79 Points: 237 Location: India
|
you can do it by enabling paging of gridview and defining page size property.
hope that helps
thanks
|
|
Rank: Advanced Member Groups: Member
Joined: 1/31/2008 Posts: 41 Points: 123 Location: India
|
well i'm using CSLA datasource. paging is not solution of my problem
my business object serve other controls in the page too. so i can not edit datasource.
can you explain me further how to tell gridview to display only first 3 rows.
many thanks
|
|
 Rank: Advanced Member Groups: Member
Joined: 11/9/2007 Posts: 223 Points: 575 Location: UK
|
well this works , tested Code:Protected Property RowCount() As Integer
Get Return _RowCount
End Get Set(ByVal value As Integer)
_RowCount = value
End Set
End Property
Private _RowCount As Integer = 0 Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs)
If e.Row.RowType = DataControlRowType.DataRow Then
RowCount = RowCount + 1
If RowCount > 3 Then
e.Row.Visible = False
End If
End If
End Sub --------------- Code:<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="ProductID"
DataSourceID="SqlDataSource1" onrowdatabound="GridView1_RowDataBound">
<Columns>
<asp:BoundField DataField="ProductID" HeaderText="ProductID" InsertVisible="False"
ReadOnly="True" SortExpression="ProductID" />
<asp:BoundField DataField="ProductName" HeaderText="ProductName" SortExpression="ProductName" />
</Columns>
</asp:GridView>
|
|
|
Guest |