I have a Radgrid that is populated from a Stored Procedure that
dynamically creates columns. Therefore, I have created the RadGrid as
follows:
Now,
the datasource is based on the selected value of a number of controls,
but what I need is to change the dataformatString on every column based
on the selectedValue of the radComboBox. I attempted to put this in the
ColumnCreated sub as follows:
The
issue that I'm having is that apparently ColumnCreated isn't hit on
postback, and I need to know a better place to put the above code
snippet. I've tried putting it in the ItemDataBound sub, but I do so
using a for each column in rgMetricsTrending.Columns, and the count is
always 0, so it never changes. The format changes to what I want, based
on the selection, but unfortunately, it doesn't change when
selectedValue of the Rad Combo Box changes and rebinds...any help would
be greatly appreciated.
| <telerik:RadGrid runat="server" ID="rgMetricsTrending" AutoGenerateColumns="true"> |
| </telerik:RadGrid> |
| Private Sub rgMetricsTrending_ColumnCreated(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridColumnCreatedEventArgs) Handles rgMetricsTrending.ColumnCreated |
| Select Case e.Column.UniqueName |
| Case "ExpandColumn" |
| Case "TimeFrame" |
| Case Else |
| Dim col As GridNumericColumn = CType(e.Column, GridNumericColumn) |
| Select Case rcbMetrics.SelectedValue |
| Case Enums.TrendingMetrics.Abandons, Enums.TrendingMetrics.ACD_Calls, Enums.TrendingMetrics.Calls_Offered |
| 'SET FORMAT TO A NUMBER |
| col.DataFormatString = "{0:g}" |
| Case Enums.TrendingMetrics.AHT, Enums.TrendingMetrics.AHT_Adj, Enums.TrendingMetrics.ASA |
| 'CAST AND FORMAT AS DATE/TIME |
| Case Enums.TrendingMetrics.Contact_Rate, Enums.TrendingMetrics.Pct_Abandoned, Enums.TrendingMetrics.Pct_Transfer, Enums.TrendingMetrics.Service_Level |
| 'SET FORMAT TO PERCENT W/ 2 DECIMAL PLACES |
| col.DataFormatString = "{0:p2}" |
| End Select |
| End Select |
| End Sub |