English 中文(简体)
网格过滤器
原标题:filtering rows in a gridview

我有一个包含用户信息的网格,一个栏是用户加入系统的日期。

可否使用<> GridView.onRowCreated methods toeck if theuser was supplemented within a given time framework? 如果在时间框架内添加用户,那么如果没有增加,则不会增加这一增长。

Note that I can t modify the datasource of the gridview, so I need to do this somehow as the gridview is being created.

最佳回答

您可使用<代码>RowBoundData,并根据您的某种条件设置茶叶。

Protected Sub GridView_RowDataBound(sender As Object, e As GridViewRowEventArgs)
    If e.Row.RowType = DataControlRowType.DataRow Then
        e.Row.Visible = True   base on some condition
    End If
End Sub

Another Method is to filter your Data. pass the filter expression in the below function and it will return you the desired output. You can do this before your binding.

Public NotInheritable Class GetFilteredData
    Private Sub New()
    End Sub
    <System.Runtime.CompilerServices.Extension> _
    Public Shared Function FilterDataTable(Dt As DataTable, FilterExpression As String) As DataTable
        Using Dv As New DataView(Dt)
            Dv.RowFilter = FilterExpression
            Return Dv.ToTable()
        End Using
    End Function
End Class
问题回答

您可以筛选出你的网格数据来源,并受电网格约束取决于你在什么地方的状况。 这比把情况放在网格活动上容易解决。

Cheers!!





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签