Home > DeveloperSection > Forums > ControlID is not recognized in code behind
Tanuj Kumar

Total Post:134

Points:940
Posted on    September-29-2014 12:39 AM

 ASP.Net ASP.Net 
Ratings:


 1 Reply(s)
 725  View(s)
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.



Sumit Kesarwani

Total Post:378

Points:2694
Posted on    September-29-2014 1:02 AM

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

        }

 }


Don't want to miss updates? Please click the below button!

Follow MindStick