ControlID is not recognized in code behind

Total Post:134

Points:940
 1309  View(s)
Ratings:
Rate this:

This is my asp code 

<tr class="footer" runat="server">
    <td colspan="4" runat="server">* By WWW.Play.org
       <asp:DropDownList AutoPostBack="true" runat="server" ID="callDispositionSelector" OnSelectedIndexChanged="callDispositionChanged">
           <asp:ListItem Value="-1">Select Disposition Reason</asp:ListItem>
           <asp:ListItem Value="1">Reservation</asp:ListItem>
           <asp:ListItem Value="2">Change of Reservation</asp:ListItem>
           <asp:ListItem Value="3">Cancellation</asp:ListItem>
           <asp:ListItem Value="4">Wait List</asp:ListItem>
           <asp:ListItem Value="5">Other</asp:ListItem>
       </asp:DropDownList>
    </td>
</tr>

In code behind, I am not able to type this callDispositionSelector. In other words, visual studio doesn't recognize that id.

  1. Post:378

    Points:2694
    Re: ControlID is not recognized in code behind

    Hi tanuj, 


    try this:

    protected void lst_ItemDataBound(object sender, ListViewItemEventArgs e)

     {

           if (e.Item.ItemType == ListViewItemType.DataItem)

            {

                DropDownList ddl= (DropDownList)e.Item.FindControl("callDispositionSelector");

            }

     }

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!