findcontrol in Listview ItemSeparatorTemplate

J

John

What is the correct vb code to find the separator row in itemdatabound
event, this does not find it?

Dim rowSep As HtmlTableRow = e.Item.FindControl("NonBill")

<ItemSeparatorTemplate>

<tr id="NonBill" runat="server">

</tr>

</ItemSeparatorTemplate>



Thanks

John
 
S

Stan

What is the correct vb code to find the separator row in itemdatabound
event, this does not find it?

Dim rowSep As HtmlTableRow = e.Item.FindControl("NonBill")

<ItemSeparatorTemplate>

<tr id="NonBill" runat="server">

</tr>

</ItemSeparatorTemplate>

Thanks

John

Your code should include a test for the item type before attempting
the assignment.
 
J

John

Thanks for your reply,

I've added the following but no avail, the separator is rendering so I know
it is there?

If e.Item.ItemType = ListItemType.Separator Then

Dim sep As HtmlTableRow = e.Item.FindControl("NonBill")

If Not sep Is Nothing Then

sep.Style.Add("background-color", "blue")

sep.Style.Add("height", "50px")

sep.Style.Add("width", "100%")

End If

End If



Thanks

John
 
M

Munna

Hi

I am not sure whither this fits to your requirement or not... i few of
the cases
i used this trick and i thought it can be worth sharing .
well there is no direct interface to get a grab on the item separator
template of list view...
since the itemseparatortempate is a
System.Web.UI.CompiledTemplateBuilder.
but there is a workaround to get a grab each time a separator is
create...

here it goes...

first of all first you got to define your separator with a load or
init event...

<ItemSeparatorTemplate>
<asp:Button ID="somebutton" runat="server"
Text="yahoo" OnLoad ="doSomething" />
</ItemSeparatorTemplate>

and in your codebehind add a public method

public void doSomething(object sender, EventArgs e)
{

//your code will go here..

}

each time the button will get instantiated it will raise the
dosomething event...

Best of luck

Munna
www.munna.shatkotha.com
www.munna.shatkotha.com/blog
www.shatkotha.com
 
J

John

Thanks great tip, I did an onload on the ,<tr> element as you advised and it
gives me full access using sender.findcontrol.

John
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,769
Messages
2,569,577
Members
45,052
Latest member
LucyCarper

Latest Threads

Top