1

我正在尝试为radgrid. 当我尝试以下操作时,我似乎无法找到过滤器控件,没有任何反应。

foreach (GridFilteringItem filterItem in InitAlerts.MasterTableView.GetItems(GridItemType.FilteringItem))
{
    RadComboBox initLoans = (RadComboBox)filterItem.FindControl("InitLoan");

    var loannumber = (from DataRow dRow in initTable.Rows
                        select new { loan_number = dRow["loan_loan_number"] }).Distinct().ToList(); 

    initLoans.DataSource = loannumber;
    initLoans.DataBind();
    Label1.Text = initLoans.ID.ToString();
}

此外,这只是在运行Page_Load,如果这有所作为......

4

1 回答 1

1

您需要在 radgrid 的项目数据绑定事件中获取过滤器

   Protected Sub gvRadGrid_ItemDataBound(ByVal sender As Object, ByVal e As GridItemEventArgs)
        'filter logic
        If e.Item.ItemType = GridItemType.FilteringItem Then
            Dim filterItem As GridFilteringItem = CType(e.Item, GridFilteringItem)
            Dim cbcombobox As RadComboBox = TryCast(filterItem.FindControl("cbcombobox "), RadComboBox)

cbcombobox .Datasource = 'your datasource'
cbcombobox .databind
        End If

end sub

当然这是用 VB 编写的,但我相信你可以将它转换为 C#

这是我通过 VB 到 C# 转换器的初步转换。它确实总是打得很好,但至少这是一个开始。

protected void gvRadGrid_ItemDataBound(object sender, GridItemEventArgs e)
{
    //filter logic
    if (e.Item.ItemType == GridItemType.FilteringItem) {
        GridFilteringItem filterItem = (GridFilteringItem)e.Item;
        RadComboBox cbcombobox = filterItem.FindControl("cbcombobox ") as RadComboBox;

        //your datasource'
        cbcombobox.Datasource = //your datasource
  cbcombobox.databind;
    }

}
于 2014-03-21T21:10:50.280 回答