简体   繁体   中英

how do i view the asp:textbox inside rgroups repeater need solution in vb.net

Why can't i access this textbox inside the repeater I have used the following on the rgroups itemdatabind no matter what i do it says the object cannot be referenced. Please supply any answer in vb.net

<asp:Repeater ID="rGroups"  Runat="server">  
<HeaderTemplate>
  <ul id="prod_nav" class="clearfix">  
<asp:TextBox ID="txt"  Text="<%#DataBinder.Eval(Container.DataItem,"groupid")%>" runat="server"> 
  </asp:TextBox> 
</HeaderTemplate>   
<ItemTemplate>        
 <li class="top"><a href="05-Pink-02-Category-List.html" class="top_link">  
<span class="down">      <%#D ataBinder.Eval(Container.DataItem,"groupname")%></span></a>   
  <asp:Repeater ID="rSubgroups"  Runat="server">          
 <HeaderTemplate>                    
 <ul class="sub">                  
 <li class="clearfix">    
               <ul>       
 </HeaderTemplate>            <ItemTemplate> 

         <li><a href="default.aspx?subgrp=<%#DataBinder.Eval(Container.DataItem,"subgroupId")%>"><%#DataBinder.Eval(Container.DataItem,"subgroupname")%></a></li>  
      </ItemTemplate>        
<FooterTemplate>                    </ul>                  </li>                </ul>            </FooterTemplate>    


protected void rGroups_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
    if (e.Item.ItemType == ListItemType.Header) // For Header
    {
        TextBox txt = e.Item.FindControl("txt") as TextBox;
    }
} 

VB.Net:

Protected Sub rGroups_ItemDataBound(sender As Object, e As RepeaterItemEventArgs) Handles rGroups.ItemDataBound
    If e.Item.ItemType = ListItemType.Header Then
        ' For Header '
        Dim txt As TextBox = TryCast(e.Item.FindControl("txt"), TextBox)
    End If
End Sub

Repeater.ItemDataBound

yes you can access to this textbox, but it is not a pretty code:

you have to call the FindControl function on required the repeateritem.cotrols

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM