我想在我的項目中顯示一列Telerik RadGrid中的複選框。 我的網格的數據源是一個對象列表。 如何以編程方式執行此操作?Telerik UI ASP.net RADGRID以編程方式設置複選框的列
p.s. 任何編程語言的答案可以理解
我的代碼:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
setColumnsOnGrid(Of object)(lst, RadGrid1, ArrayNameFilds:={"column1", "column2", "column3 ", "etc."})
End If
End Sub
Private Sub setColumnsOnGrid(Of T)(ByVal lst As List(Of T), ByVal grdName As RadGrid, ByVal ArrayNameFilds As Array)
Dim nameFiled As String
grdName.DataSource = lst
grdName.AllowMultiRowSelection = True
grdName.MasterTableView.AutoGenerateColumns = False
Dim boundColumn As GridBoundColumn
For i As Integer = 0 To ArrayNameFilds.Length - 1
nameFiled = ArrayNameFilds(i).ToString()
boundColumn = New GridBoundColumn()
grdName.MasterTableView.Columns.Add(boundColumn)
boundColumn.DataField = nameFiled
boundColumn.HeaderText = nameFiled
Next
End Sub
我的aspx:
<telerik:RadGrid ID="grd_test" runat="server" AllowFilteringByColumn="True" AllowPaging="True" AllowSorting="True" CellSpacing="0" GridLines="None"> <ClientSettings> <Scrolling AllowScroll="True" UseStaticHeaders="True" /> </ClientSettings> </telerik:RadGrid>
感謝,鏈接顯示瞭如何只在設計(ASPX)中執行此操作,而不是在代碼背後 – DUKEiLL
快樂您找到解決方案! –