【发布时间】:2014-01-09 21:28:33
【问题描述】:
通常对RadGrid 中的列进行排序,我在GridTemplateColumn 中使用sortexpression 和text。但现在不同了;这里我有一个RadGrid 有几列,它们都是GridTemplateColumns。我有一个绑定RadGrid 的集合。
<telerik:GridTemplateColumn ItemStyle-BorderWidth="0" ItemStyle-HorizontalAlign="Left"
HeaderStyle-Font-Bold="true" UniqueName="CustomerSupplierName" ShowSortIcon="true">
<ItemTemplate>
<asp:Label ID="lblSupplierName" runat="server" />
<%-- Text='<%# Eval("SupplierNameText")%>'/>--%>
</ItemTemplate>
</telerik:GridTemplateColumn>
这是其中一列。现在在数据绑定函数中,我填充了网格。我的页面上有一个单选按钮列表,完全远离这个网格。根据其选择的索引,我更改要填充到此特定列 (UniqueName="CustomerSupplierName") 中的值。像这样
在 ItemDataBound 中:
If rblCustomersSuppliers.SelectedIndex = 0 Then
Dim lblSupplierName As Label = e.Item.FindControl("lblSupplierName")
lblSupplierName.Text = cont.SupplierNameText
Else
Dim lblSupplierName As Label = e.Item.FindControl("lblSupplierName")
lblSupplierName.Text = cont.CustomerOrganization
End If
所以我要么根据选择绑定供应商名称或客户组织。现在我需要这个列是可排序的。我怎么做?如果您需要更多信息,请询问。谢谢
编辑: 项目数据绑定
If TypeOf e.Item Is GridHeaderItem Then
If rblCustomersSuppliers.SelectedIndex = 0 Then
rgContractHistory.MasterTableView.GetColumn("CustomerName").Visible = False
rgContractHistory.MasterTableView.GetColumn("SupplierName").Visible = True
Else
item("CustomerName").Text = "Customer"
rgContractHistory.MasterTableView.GetColumn("CustomerName").Visible = True
rgContractHistory.MasterTableView.GetColumn("SupplierName").Visible = False
End If
End If
【问题讨论】:
标签: sorting telerik expression radgrid