Hiding column in Repeater

Ya Ya

Newcomer
Joined
Sep 29, 2006
Messages
1
Hi, hope some experts here can help me solve my small problem. I have a Repeater with e.g. columns A, B, C, D. D is extracted from a field that determines whether that row has been validated. So, by default, D will be empty if it is a newly created item.

My problem is, I would like to hide D when it is a new item. Only to show D when this row has been validated. I would also like to hide it's header too. I can do this in GridView, but not sure how to in Repeater and I definitely has to use Repeater.

This is what I have done in GridView, hope someone can give me an idea how to do it in Repeater.

foreach ( GridViewRow row in gv.Rows)
{
gv.HeaderRow.Cells[ 0 ].Visible = false;
row.Cells[ 0 ].Visible = false;
}



Thanks in advance!
 
Are you sure you have to use a Repeater? The Repeater control dont have columns like the gridview.
Anyway, you can control the visibility of any webcontrol inside the itemtemplate of the repeater. You just have to use the ItemDataBound event, get the webcontrol reference using the FindControl method and set its visibility.

Hope this helps.
 
I have used this method before .. worked really nice:

The panel doesn't render anything if it's not visible. So no worries about getting the table tags jacked up from a div tag in between the row tags.

//HTML SOURCE
<itemtemplate>

<asp:panel ........... visible='<%# IsNotNewItem(whatever) %>

..... Row information here

</asp:panel>


</itemtemplate>

//CODE BEHIND

public Boolean IsNotNewItem(object param)
{
code here ...

return trueorfalse;

}
 
Back
Top