Solved

Bind string value to AccessDataSource Parameter

Posted on 2010-11-16
8
700 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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Gridview alignment 1 20
Regex validation 2 25
ASP.net 2015 Syncing Azure web app projects on two machines 2 21
Deploying to Azure 3 29
This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

803 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