DLockwood
asked on
Bind string value to AccessDataSource Parameter
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.Sel ectParamet ers(0).Def aultValue = sUserID
End Sub
Why doesn't Drop Down List show values based on the Parameter?
Dim sUserID As String = User.Identity.Name
PermittedAccessList_DS.Sel
End Sub
Why doesn't Drop Down List show values based on the Parameter?
Try calling Databind() on the Dropdown control after setting the parameter.
ASKER
Doesn't fix anything.
Still doesn't work.
Still doesn't work.
Can you post some more snippets of the code? Specifically the accessdatasource and the droplist.
ASKER
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.
Funny thing is that I read I should put my Code Behind into the DDL_Selecting Event. I do not even get that option.
ASKER
DDL:
<asp:DropDownList ID="DDLTables" runat="server"
AutoPostBack="True"
DataSourceID="PermittedAcc essList_DS "
DataTextField="TableSecuri ty"
DataValueField="TableSecur ity"
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/Outco mesDB.mdb"
SelectCommand="SELECT tlkp_TableSecurity.TableSe curity FROM (tlkp_TableSecurity INNER JOIN tlkp_UserSecurity ON tlkp_TableSecurity.ID = tlkp_UserSecurity.TABLE) WHERE (Username = ?) ORDER BY tlkp_TableSecurity.TableSe curity">
<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.Sel ectParamet ers(0).Def aultValue = sUserID
DDLTables.DataBind()
End Sub
DOESN'T WORK
<asp:DropDownList ID="DDLTables" runat="server"
AutoPostBack="True"
DataSourceID="PermittedAcc
DataTextField="TableSecuri
DataValueField="TableSecur
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
DataFile="~/App_Data/Outco
SelectCommand="SELECT tlkp_TableSecurity.TableSe
<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.Sel
DDLTables.DataBind()
End Sub
DOESN'T WORK
ASKER
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_Sel ecting(ByV al sender As Object, ByVal e As System.Web.UI.WebControls. SqlDataSou rceSelecti ngEventArg s) Handles PermittedAccessList_DS.Sel ecting
Dim sUserID As String = "David"
PermittedAccessList_DS.Sel ectParamet ers(0).Def aultValue = sUserID
End Sub
But, even when I put the code like this, it doesn't work.....
Private Sub PermittedAccessList_DS_Sel
Dim sUserID As String = "David"
PermittedAccessList_DS.Sel
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Answered it myself.