Team,
I need to update Header Template controls data from code behind during Item_Databound. Suggest possible solution.
ASPX
-------
<telerik:GridTemplateColumn UniqueName="Leg" HeaderText="Leg1">
<HeaderTemplate>
<asp:HiddenField ID="hdnLeg1" runat="server" />
<asp:Label ID="lbLeg1" Text="" runat="server" />
</HeaderTemplate>
<ItemTemplate>
<asp:DropDownList ID="DropDownList1" runat="server">
</asp:DropDownList>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn UniqueName="Leg" HeaderText="Leg1">
<HeaderTemplate>
<asp:HiddenField ID="hdnLeg2" runat="server" />
<asp:Label ID="lbLeg2" Text="" runat="server" />
</HeaderTemplate>
<ItemTemplate>
<asp:DropDownList ID="DropDownList2" runat="server">
</asp:DropDownList>
</ItemTemplate>
</telerik:GridTemplateColumn>
.............
ASPX.CS
// Code must update each Hidden variables with it's ID and Label Text for Grid Column Header
if (e.Item is GridHeaderItem)
{
int PreviousLegIDIndex = 0;
int counter = 0;
foreach (GridHeaderItem headerItem in dgPassanger.MasterTableView.GetItems(GridItemType.Header))
{
counter = 0;
foreach (var Leg in Log.Legs)
{
counter++;
if (counter > PreviousLegIDIndex)
{
foreach (var headerControl in headerItem["Leg"].Controls)
{
PreviousLegIDIndex = counter;
if (headerControl.GetType() == typeof(Label))
{
Label lbHeader = (Label)headerControl;
lbHeader.Text = tripLeg.POLegsDescription;
}
if (headerControl.GetType() == typeof(HiddenField))
{
HiddenField hdnHeader = (HiddenField)headerControl;
hdnHeader.Value = tripLeg.LegID.ToString();
}
}
break;
}
}
}
}
I need to update Header Template controls data from code behind during Item_Databound. Suggest possible solution.
ASPX
-------
<telerik:GridTemplateColumn UniqueName="Leg" HeaderText="Leg1">
<HeaderTemplate>
<asp:HiddenField ID="hdnLeg1" runat="server" />
<asp:Label ID="lbLeg1" Text="" runat="server" />
</HeaderTemplate>
<ItemTemplate>
<asp:DropDownList ID="DropDownList1" runat="server">
</asp:DropDownList>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn UniqueName="Leg" HeaderText="Leg1">
<HeaderTemplate>
<asp:HiddenField ID="hdnLeg2" runat="server" />
<asp:Label ID="lbLeg2" Text="" runat="server" />
</HeaderTemplate>
<ItemTemplate>
<asp:DropDownList ID="DropDownList2" runat="server">
</asp:DropDownList>
</ItemTemplate>
</telerik:GridTemplateColumn>
.............
ASPX.CS
// Code must update each Hidden variables with it's ID and Label Text for Grid Column Header
if (e.Item is GridHeaderItem)
{
int PreviousLegIDIndex = 0;
int counter = 0;
foreach (GridHeaderItem headerItem in dgPassanger.MasterTableView.GetItems(GridItemType.Header))
{
counter = 0;
foreach (var Leg in Log.Legs)
{
counter++;
if (counter > PreviousLegIDIndex)
{
foreach (var headerControl in headerItem["Leg"].Controls)
{
PreviousLegIDIndex = counter;
if (headerControl.GetType() == typeof(Label))
{
Label lbHeader = (Label)headerControl;
lbHeader.Text = tripLeg.POLegsDescription;
}
if (headerControl.GetType() == typeof(HiddenField))
{
HiddenField hdnHeader = (HiddenField)headerControl;
hdnHeader.Value = tripLeg.LegID.ToString();
}
}
break;
}
}
}
}