findcontrol in Listview ItemSeparatorTemplate

  • Thread starter Thread starter John
  • Start date Start date
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
 
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.
 
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
 
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
 
Thanks great tip, I did an onload on the ,<tr> element as you advised and it
gives me full access using sender.findcontrol.

John
 
Back
Top