checkbox, dropdownlist, and databinding

B

brian.newman

I've created a dropdownlist whose values are drawn from an Access
database. This list of items represents a user account. In the same
record is a boolean field which records whether the user is an
administrator.
On my web form, I want a checkbox labelled "Is Admin" which will take
the appropriate value from the Access database depending on which value
is chosen in the dropdownlist.
I'm using a checkboxlist in this case as it has databinding built into
it. I know my AccessDBConnection_UserList is working correctly because
it populates the dropdownlist with the right values and I know that my
AccessDBConnection_IsAdmin is working correctly because I run a test
test query on it from inside Visual Studio.
However, when I run the website, the checkboxlist is not working
correctly. It doesn't take the right values.
Anyway, here's my code

<asp:AccessDataSource ID="AccessDataSource_UserList"
runat="server" DataFile="~/App_Data/AvailReport.mdb"
OnSelecting="AccessDataSource1_Selecting"
SelectCommand="SELECT DISTINCT [Name] FROM [UserList]">
</asp:AccessDataSource>
<asp:DropDownList ID="DropDownList1" runat="server"
AutoPostBack="True" DataSourceID="AccessDataSource_UserList"
DataTextField="Name" DataValueField="Name" Style="z-index:
103; left: 41px; position: absolute;
top: 38px">
</asp:DropDownList>
<asp:AccessDataSource ID="AccessDataSource_AdminInfo"
runat="server" DataFile="~/App_Data/AvailReport.mdb"
SelectCommand="SELECT [Name], [isAdmin] FROM [UserList]
WHERE ([Name] = ?)">
<SelectParameters>
<asp:ControlParameter ControlID="DropDownList1"
DefaultValue="false" Name="Name"
PropertyName="SelectedValue" Type="String" />
</SelectParameters>
</asp:AccessDataSource>
<asp:CheckBoxList ID="CheckBoxList1" runat="server"
DataSourceID="AccessDataSource_AdminInfo"
DataTextField="Name" DataValueField="isAdmin"
Style="z-index: 104; left: 337px;
position: absolute; top: 59px">
</asp:CheckBoxList>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top