ControlID is not recognized in code behind

Total Post:134

 1416  View(s)
Rate this:

This is my asp code 

<tr class="footer" runat="server">
    <td colspan="4" runat="server">* By
       <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>

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

  1. Post:378

    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");