I'm trying to include a dropdownlist in my gridview and then bind data to that dropdownlist.

I have come across an error:

error CS0103: The name 'sortOrderDropDown2' does not exist in the current context at System.Web.Compilation.AssemblyBuilder.Compile()

Now i'm not sure why I get this error as my asp file clearly has a dropdown with the ID="sortOrderDropDown2"

                <asp:DropDownList ID="sortOrderDropDown2" AutoPostBack="true" runat="server" Visible="true"> </asp:DropDownList>

Now here is my PageLoad code in my c# file:

protected void Page_Load(object sender, EventArgs e)
        if (!Page.IsPostBack)

        //Get first/last sortOrder from XML file and display
        ArrayList sortOrderArrayMax = sortOrderListMax();
        int maxSortOrder = sortOrderArrayMax.Count - 1;

        string sortOrderMax = sortOrderArrayMax[maxSortOrder].ToString();

        sortOrderHigh.Text = sortOrderMax;

        //My dropdown list using the datasource from the above arraylist - gets max value.

        sortOrderDropDown2.DataSource = sortOrderArrayMax;

        ArrayList sortOrderArrayMin = sortOrderListMin();
        int minSortOrder = sortOrderArrayMin.Count - 1;

        string sortOrderMin = sortOrderArrayMin[minSortOrder].ToString();

        sortOrderLow.Text = sortOrderMin;




Is there any reason I get this error as it clearly is there?

Thank you

6 Years
Discussion Span
Last Post by crishlay

in gridview you can not get directly any ID value for binding or any other purpose, use Rowdatabound/Itemdatabound in gridview for getting Dropdownlist id values or binding Dropdownlist values

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.