i want to hide some row in headerTemplate block in my asp.net page this is my apsx page code:
<HeaderTemplate>
<table class="uk-table uk-table-hover uk-table-striped">
<thead>
<tr>
<th class="uk-width-1-10">numbr 1</th>
<th class="uk-width-1-10">numbr 2</th>
<th class="uk-width-2-10">numbr 3</th>
</tr>
</thead>
<tbody>
</HeaderTemplate>
<ItemTemplate>
...
and i chenged to this to Hide number 3
<HeaderTemplate>
<table class="uk-table uk-table-hover uk-table-striped">
<thead>
<tr>
<th class="uk-width-1-10">numbr 1</th>
<th class="uk-width-1-10">numbr 2</th>
<th class="uk-width-2-10"><asp:Label runat="server" ID="tdInfoHeader" Visible="true">numbr 3</asp:Label></th>
</tr>
</thead>
<tbody>
</HeaderTemplate>
<ItemTemplate>
...
but in my C# code part, i cant changed tdInfoHeader.visible =false
, how could i Hide Number 3 in my C# part?
You can use Repeater.ItemDataBound event to achieve this.
First, make sure you set the OnItemDataBound
property to the name of the event handler method in your aspx code, let's say the name is rpt1_ItemDataBound
:
<asp:Repeater ID="rpt1" runat="server" OnItemDataBound="rpt1_ItemDataBound">
then hide tdInfoHeader
in rpt1_ItemDataBound
method:
protected void rpt1_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Header)
{
Label tdInfoHeader = (Label)e.Item.FindControl("tdInfoHeader");
tdInfoHeader.Visible = false;
}
}