Compiler Error Message: CS1061 ASPX

I am trying to code a drop down list that will have an OnSelectedIndexChanged event but i can't make it work.

So here's the code on my .aspx

<asp:DropDownList ID="DDLSample" OnSelectedIndexChanged="DDLSample_SelectedIndexChanged" runat="server">
                    <asp:ListItem Text="Sample1" Value="0"></asp:ListItem>
                    <asp:ListItem Text="Sample2" Value="1"></asp:ListItem>
                    <asp:ListItem Text="Others..." Value="2"></asp:ListItem>
                </asp:DropDownList> 

and a textbox

<asp:TextBox  ID="txtOthers" runat="server" Visible ="false" CssClass="form-control" ></asp:TextBox>

What I plan to do is that when "Others..." is selected from the drop down list, it will show the Others field.

on my aspx.cs, I have this code

protected void Page_Load(object sender, EventArgs e)
    {
        DDLSample.SelectedIndexChanged += new EventHandler(DDLSample_SelectedIndexChanged);
        DDLSample.AutoPostBack = true;
    }

    void DDLSample_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (DDLFindings.SelectedValue.ToString() == "2")
            txtOthers.Visible = true;
        else
            txtOthers.Visible = false;
    }

but still, I keep getting this error

CS1061: 'sample_aspx' does not contain a definition for 'DDLSample_SelectedIndexChanged' and no extension method 'DDLSample_SelectedIndexChanged' accepting a first argument of type 'sample_aspx' could be found (are you missing a using directive or an assembly reference?)


Click here view more answers http://ift.tt/1YHObtR