G
Guest
I have a datagrid and there are 2 columns where I may or may not want to print based upon a condition.
I thought I could use the OnItemCreated Event and then turn the visibility flag on or off as the condition required, but I can not seem to be able to find and turn on the visibility property.
Here is how these controls are defined in my grid (they are the 6th and 7th columns in my datagrid)....
public void dgCalendarOnItemCreated(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item | e.Item.ItemType ==
ListItemType.AlternatingItem)
{
Control ctrl = e.Item.Controls[5];
ctrl.Visible=true;
ctrl = e.Item.Controls[6];
ctrl.Visible = true;
}
}
<asp:TemplateColumn HeaderText="Product Data Mgr<br>Cut-Off Date" Visible="False">
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem,"PDM_CUTOFF_PERIOD") %>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Product Data Mgr<br>Cut-Off Time" Visible="False">
<ItemTemplate>
<%# DataBinder.EvaContainer.DataItem,"PDM_CUTOFF_PERIOD_Time") %>
</ItemTemplate>
</asp:TemplateColumn>
this does not make my column visible.
Any ideas on what I must do to turn these columns visibility property to "true"
I thought I could use the OnItemCreated Event and then turn the visibility flag on or off as the condition required, but I can not seem to be able to find and turn on the visibility property.
Here is how these controls are defined in my grid (they are the 6th and 7th columns in my datagrid)....
public void dgCalendarOnItemCreated(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item | e.Item.ItemType ==
ListItemType.AlternatingItem)
{
Control ctrl = e.Item.Controls[5];
ctrl.Visible=true;
ctrl = e.Item.Controls[6];
ctrl.Visible = true;
}
}
<asp:TemplateColumn HeaderText="Product Data Mgr<br>Cut-Off Date" Visible="False">
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem,"PDM_CUTOFF_PERIOD") %>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Product Data Mgr<br>Cut-Off Time" Visible="False">
<ItemTemplate>
<%# DataBinder.EvaContainer.DataItem,"PDM_CUTOFF_PERIOD_Time") %>
</ItemTemplate>
</asp:TemplateColumn>
this does not make my column visible.
Any ideas on what I must do to turn these columns visibility property to "true"