Solved

Bind string value to AccessDataSource Parameter

Posted on 2010-11-16
8
704 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 

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
 

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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.
Suggested Courses

739 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