I am currently dynamically changing the Header Text of one of my grids using the following code:
I have also used this code as well but get the same result:
The problem I am running into is when I sort another grid on my page the headers resort back to Yr1, Yr2, Yr3, etc....
I am not sure where my error is, but I would be thrilled with any assistance.
Thanks,
Brad
Protected Sub gvYearByYearValueProjection_DataBound(sender As Object, e As System.EventArgs) Handles gvYearByYearValueProjection.DataBound Dim Season As Integer = Utility.GetCurrentSeason Dim headerItem As GridHeaderItem = gvYearByYearValueProjection.MasterTableView.GetItems(GridItemType.Header)(0) headerItem("Yr1").Text = Convert.ToString(Season & "-" & Right(Season, 2) + 1) headerItem("Yr2").Text = Convert.ToString(Season + 1 & "-" & Right(Season, 2) + 2) headerItem("Yr3").Text = Convert.ToString(Season + 2 & "-" & Right(Season, 2) + 3) headerItem("Yr4").Text = Convert.ToString(Season + 3 & "-" & Right(Season, 2) + 4) headerItem("Yr5").Text = Convert.ToString(Season + 4 & "-" & Right(Season, 2) + 5) headerItem("Yr6").Text = Convert.ToString(Season + 5 & "-" & Right(Season, 2) + 6) End SubI have also used this code as well but get the same result:
Protected Sub gvYearByYearValueProjection_ItemDataBound(sender As Object, e As Telerik.Web.UI.GridItemEventArgs) Handles gvYearByYearValueProjection.ItemDataBound Dim Season As Integer = Utility.GetCurrentSeason If TypeOf e.Item Is GridHeaderItem Then Dim header As GridHeaderItem = DirectCast(e.Item, GridHeaderItem) header("Yr1").Text = Convert.ToString(Season & "-" & Right(Season, 2) + 1) header("Yr2").Text = Convert.ToString(Season + 1 & "-" & Right(Season, 2) + 2) header("Yr3").Text = Convert.ToString(Season + 2 & "-" & Right(Season, 2) + 3) header("Yr4").Text = Convert.ToString(Season + 3 & "-" & Right(Season, 2) + 4) header("Yr5").Text = Convert.ToString(Season + 4 & "-" & Right(Season, 2) + 5) header("Yr6").Text = Convert.ToString(Season + 5 & "-" & Right(Season, 2) + 6) End If If TypeOf e.Item Is GridDataItem Then Dim item As GridDataItem = DirectCast(e.Item, GridDataItem) End IfEnd SubThe problem I am running into is when I sort another grid on my page the headers resort back to Yr1, Yr2, Yr3, etc....
I am not sure where my error is, but I would be thrilled with any assistance.
Thanks,
Brad