I had AutoGenerateColumns set to True, pointed my dataset to RadGrid1.DataSource, and everything worked fine. Now I set AutoGeneateColumns to False and manually add the columns. Here's my simplified code for test purposes...
| Protected Sub CreateColumns(ByVal ds As DataSet) |
| RadGrid1.Columns.Clear() |
| RadGrid1.AutoGenerateColumns = False |
| Dim dt As DataTable = ds.Tables(0) |
| For i As Integer = 0 To dt.Columns.Count - 1 |
| AddColumn(dt.Columns(i).ColumnName) |
| Next |
| End Sub |
| Protected Sub AddColumn(ByVal strColumnName As String) |
| Dim col As New GridBoundColumn |
| col.DataField = strColumnName |
| col.HeaderText = strColumnName |
| RadGrid1.Columns.Add(col) |
| End Sub |
After doing this, if I click on the Header to sort the column, the grid does not sort, and all the HeaderText along the top disappears. Filtering also throws this error: "is neither a DataColumn nor a DataRelation for table DefaultView". Am I missing some setting? If it helps, here's my RadGrid...
| <telerik:RadGrid ID="RadGrid1" runat="server" AllowFilteringByColumn="True" AllowPaging="True" |
| AllowSorting="True" GridLines="None" AutoGenerateColumns="False"> |
| <ClientSettings> |
| <Selecting AllowRowSelect="True" /> |
| </ClientSettings> |
| </telerik:RadGrid> |