Last post Nov 29, 2008 09:34 PM by momoaal
Mar 17, 2006 12:20 PM|gmeadows|LINK
I want to set a web control button to be enabled or disabled based on the value of a record in a specific field in my database. Can I use the AccessDataSource control to do this?
My push button has an id="button1"
For example my sql query would look like this:
SELECT pwd from users where pwd = admin
then in my code I would write
password = pwd
if password = "admin" then
button1.enabled = true
Mar 17, 2006 04:10 PM|cashmore|LINK
You could add some code similar to below in your Page Load event - this assumes you have set the select staement of AccessDataSource1 to retrieve one reocrd for a particular user.
Dim dv as System.Data.DataView = AccessDataSource1.Select(DataSourceSelectArguments.Empty)
if dv.ToTable.Rows(0)("pwd") = "admin" Then
button1.enabled = True
button1. enabled = False
Mar 17, 2006 04:17 PM|cashmore|LINK
Just noticed in your other post you are using Web Matrix so code I gave you probably won't work with 1.1
Have moved on to asp.net 2.0 now and can't remember how you would do it in 1.1 but think you need a datareader and use read to retrieve records.
Nov 29, 2008 09:33 PM|momoaal|LINK
thanks ... that wroks for me ... [Yes]
Nov 29, 2008 09:34 PM|momoaal|LINK