Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Bind string value to AccessDataSource Parameter

Posted on 2010-11-16
8
Medium Priority
?
708 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

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…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

610 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