[英]Getting the filter control in a RadGrid
I'm trying to databind a combobox for a filter on a radgrid
. 我正在尝试对
radgrid
上的过滤器的组合框进行数据绑定。 I can't seem to be able to find the filter control when i try the following, nothing happens. 当我尝试以下操作时,似乎无法找到过滤器控件,什么也没发生。
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();
}
Also, this is just running in Page_Load
, if that makes a difference... 此外,这只是在
Page_Load
运行,如果有所不同...
You need to grab the filter in the item databound event of a radgrid 您需要在radgrid的item数据绑定事件中获取过滤器
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
Of course this was written in VB but I'm sure hyou can convert it to C# 当然,这是用VB编写的,但是我敢肯定,您可以将其转换为C#
Here's a preliminary conversion that I pushed through a VB to C# converter. 这是我通过VB到C#转换器进行的初步转换。 It doens' talways play nice but at least it's a start.
它的作用总是不错,但至少这是一个开始。
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;
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.