简体   繁体   English

将Sql数据源列值选择为变量(VB.NET)

[英]Selecting Sql Data Source Column Value to Variable (VB.NET)

I have a SqlDataSource , defined in the Master Page, that gets the current user permissions for the web application Select * from portal_users where userid = @userid , where portal_users is a view i built with all the data needed. 我在母版页中定义了一个SqlDataSource ,它获取web application的当前用户权限。 Select * from portal_users where userid = @userid ,其中portal_users是我使用所有所需数据构建的视图。 I need to access the contents on the returned row so I can disable/enable site features according to the user permissions. 我需要访问返回行上的内容,以便可以根据用户权限禁用/启用网站功能。 This results in a lot of if blocks across the child pages to do it. 这导致在子页面上有很多if块来执行此操作。

I browsed around forums and I only found issues about assigning those values to controls like ie label . 我浏览了各个论坛,只发现了将这些值分配给如label类的控件的问题。 Is there a way to access the SqlDataSource from the Master Page , get the row that is returned, select 1 or more column's values and assign them to variables? 有没有一种方法可以从Master Page访问SqlDataSource ,获取返回的行,选择1个或多个列的值并将其分配给变量?

Hy It's not a good idea, use Master Page to share Data Source connections Read this post to help you: Hy这不是一个好主意,请使用母版页共享数据源连接阅读此文章可为您提供帮助:

http://forums.asp.net/t/1188088.aspx?sql+data+source+in+Master+Page http://forums.asp.net/t/1188088.aspx?sql+data+source+in+Master+Page

Regards 问候

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM