开发者

DataList on MasterPage does not exist in the current context

开发者 https://www.devze.com 2023-01-30 13:48 出处:网络
I inserted a datalist on the master page. In the code behind, I do a linq data binding and the page displays fine when browsing.

I inserted a datalist on the master page. In the code behind, I do a linq data binding and the page displays fine when browsing.

            var links = from sl in db.SiteLinks
                        where sl.PaneID == 1
                        orderby sl.SortOrder
                        select new { sl.LinkName, sl.NavUrl };

            dlSiteMenu.DataSource = links.ToList();
            dlSiteMenu.DataBind();

When I tried to build the website, however, I an error stating that the dlSiteMenu does not exist in开发者_开发问答 the current context. How is this possible? Intellisense is able to see the datalist after I type the . Any ideas how to solve this problem?

Note: I am using Visual Studio 2010.


Are you doing the databinding from the codebehind of the MasterPage or a WebForm using the MasterPage?

0

精彩评论

暂无评论...
验证码 换一张
取 消