Posted 29 Nov 2010
Link to this post
I have a snippet of vb code that is used to loop through the columns in a radgrid and save away key data relating to a user view of the grid. The data is save to a sql-server table. The code worked fine when all the columns were of type BoundColumn, however I now have a few TemplateColumns as well.
So, how can I look through the columns of the radgrid, identify the column type, pick up the current attributes from that column and save them to a Sql table.
Here is the code that I currently have which works great for BoundColumns
Dim column As Telerik.Web.UI.GridBoundColumn
For Each column In theGrid.Columns
If column.DataField.Length > 0 And column.OrderIndex > 0 Then
strSQL = "INSERT INTO wt264PageSettingsColumns (ColumnID, Text, Format, DataFormat, Visible, Value, OrderIndex, Aggregate, FooterText) SELECT '" & ColID & "', '" & RTrim(column.HeaderText) & "', '" & column.DataType.ToString & "', '" & RTrim(column.DataFormatString) & "', '" & column.Display & "', '" & RTrim(column.DataField) & "', '" & column.OrderIndex & "', CASE WHEN '" & Len(RTrim(column.FooterText)) & "' > 0 THEN 1 ELSE 0 END, '" & RTrim(column.FooterText) & "' "
Dim Command000e As SqlClient.SqlCommand = New SqlClient.SqlCommand(strSQL, myComponent.SqlConnection1)
Command000e.CommandTimeout = 5000
Thanks in advance