Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

To start with, I have a template setup that came from Microsoft for Timecard Management. This template basically tracks the project someone is working on and the specific task. On one page, it is reading a QueryString Parameter to filter data. I wanted to add a DropDown List to make selecting the projects easier to filter. However, after adding my DropDown List, and selecting the data source, it works, but as soon as I add my code to have it Post Back and set the QueryString Parameter I receive the following error.

"An error occurred during the compilation of the requested file, or one of its dependencies. The name 'DropDownList1' does not exist in the current context

Troubleshoot issues with Microsoft SharePoint Foundation.

Correlation ID: f7afad4b-9af1-43df-8671-8581925f99de"

The Following Code is what I am trying to run:

<script type="text/c#" runat="server">
                    protected void Page_Load(object sender, EventArgs e)
                    {
                                                DropDownList1.DataBind();

                        if(!IsPostBack)
                        {
                            if(Request.QueryString["Project"] == (null))
                            {
                                Response.Redirect("http://server/test/Lists/Time%20Log/ProjectDetails.aspx?Project=" + DropDownList1.SelectedValue);
                            }

                            DropDownList1.SelectedValue = Convert.ToString(Request.QueryString["Project"]);
                        }
                    }

                    protected void SelectionChanged(object sender, EventArgs e)
                    {
                        Response.Redirect("http://server/test/Lists/Time%20Log/ProjectDetails.aspx?Project=" + DropDownList1.SelectedValue);
                    }   
                </script>

And my DropDownList is declared as the following:

<asp:DropDownList runat="server" id="DropDownList1" AutoPostBack="True" DataValueField="Title" DataTextField="Title" DataSourceID="spdatasource1" OnSelectedIndexChange="SelectionChanged()">
                        </asp:DropDownList>

I have looked online or a solution, and nothing I have found was the least bit helpful. Scripting is enabled on this page in the web.config files PageParserPaths, and there is not a duplicate Page.aspx in the same directory.

Thanks in advance.

share|improve this question

1 Answer 1

Try looking in your designer.cs file and see if there is an entry for DropDownList1.

I've found that a lot of times this will get out of synch and you will have to manually create entries in there. If there is not an entry try adding this line:

protected global::System.Web.UI.WebControls.DropDownList DropDownList1;
share|improve this answer
    
I had found that as a possible solution a while back, the problem is, this template was designed by Microsoft, and I have no access to Visual Studio 2010. The tools I have available to me are SharePointDesigner 2010. I am modifying a .aspx page that was generated by the template. –  Zach Little Jul 19 '12 at 17:49

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.