Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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!

  • 3 weeks later...
Posted

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.

Posted

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;

 

}

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...