Solved

Bind string value to AccessDataSource Parameter

Posted on 2010-11-16
8
695 Views
Last Modified: 2012-05-10
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
     Dim sUserID As String = User.Identity.Name
     PermittedAccessList_DS.SelectParameters(0).DefaultValue = sUserID
End Sub

Why doesn't Drop Down List show values based on the Parameter?
0
Comment
Question by:DLockwood
  • 6
  • 2
8 Comments
 
LVL 21

Expert Comment

by:MogalManic
ID: 34156081
Try calling Databind() on the Dropdown control after setting the parameter.
0
 

Author Comment

by:DLockwood
ID: 34159752
Doesn't fix anything.

Still doesn't work.
0
 
LVL 21

Expert Comment

by:MogalManic
ID: 34159808
Can you post some more snippets of the code?  Specifically the accessdatasource and the droplist.
0
 

Author Comment

by:DLockwood
ID: 34159873
Sure, gimme a second.

Funny thing is that I read I should put my Code Behind into the DDL_Selecting Event. I do not even get that option.
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 

Author Comment

by:DLockwood
ID: 34159910
DDL:
        <asp:DropDownList ID="DDLTables" runat="server"
            AutoPostBack="True"
            DataSourceID="PermittedAccessList_DS"
            DataTextField="TableSecurity"
            DataValueField="TableSecurity"
            AppendDataBoundItems="True"
            style="text-align:
            center" Width="250px">
            <asp:ListItem Text="Select a Program to Access" Value="" />
        </asp:DropDownList>

DataSource:
<asp:AccessDataSource ID="PermittedAccessList_DS" runat="server"
        DataFile="~/App_Data/OutcomesDB.mdb"
        SelectCommand="SELECT tlkp_TableSecurity.TableSecurity FROM (tlkp_TableSecurity INNER JOIN tlkp_UserSecurity ON tlkp_TableSecurity.ID = tlkp_UserSecurity.TABLE) WHERE (Username = ?) ORDER BY tlkp_TableSecurity.TableSecurity">
        <SelectParameters>
            <asp:Parameter Name="UserName" Type="string"  />
        </SelectParameters>
    </asp:AccessDataSource>

Code Behind:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim sUserID As String = "David"
        PermittedAccessList_DS.SelectParameters(0).DefaultValue = sUserID
        DDLTables.DataBind()
End Sub

DOESN'T WORK
0
 

Author Comment

by:DLockwood
ID: 34159927
OK - So the DDL doesn't have the SELECTING event, it is the data source. Duh!

But, even when I put the code like this, it doesn't work.....

    Private Sub PermittedAccessList_DS_Selecting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceSelectingEventArgs) Handles PermittedAccessList_DS.Selecting
        Dim sUserID As String = "David"
        PermittedAccessList_DS.SelectParameters(0).DefaultValue = sUserID
    End Sub
0
 

Accepted Solution

by:
DLockwood earned 0 total points
ID: 34160049
WOW - I figuredout the problem.

How stupid is this?

Cannot use a complex query with a join. When I change the Select Command Query to be a simple statement "Select [Table], [Username] from [tlkp_UserSecurity] WHERE (Username = ?) ORDER BY t[Table]" then everything works fine.

No error message. No nothing. Just didn't work. What a waste of time.
0
 

Author Closing Comment

by:DLockwood
ID: 34186464
Answered it myself.
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now