You can handle the Selecting event of the object data source ,
Protected Sub ObjectDataSource1_Selecting(ByVal sender As System.Object, ByVal e As System.Web.UI.WebControls.ObjectDataSourceSelectingEventArgs) Handles ObjectDataSource1.Selecting
e.InputParameters("username") = Page.User.Identity.Name
End Sub
But you need to use <asp:Paramter instead of the Session Parameter.
The other way is to create a custom Paratemer that can read the username automatically ,
You can handle the Selecting event of the object data source ,
Protected Sub ObjectDataSource1_Selecting(ByVal sender As System.Object, ByVal e As System.Web.UI.WebControls.ObjectDataSourceSelectingEventArgs) Handles ObjectDataSource1.Selecting
e.InputParameters("username") = Page.User.Identity.Name
End Sub
But you need to use <asp:Paramter instead of the Session Parameter.
The other way is to create a custom Paratemer that can read the username automatically ,
afrika
Member
249 Points
860 Posts
What parameter to use in an Objectdatasource ?
Dec 20, 2008 04:09 AM|LINK
Hello,
I have a gridview, and used to use a session variable to get the user's records as thus
<SelectParameters>
<asp:SessionParameter DefaultValue="1" Name="username" SessionField="username" Type="String" />
</SelectParameters>
However, I want to use the membership login name to get the values, how do i go about it ?
Membership.GetUser().UserName.ToString()
What is the parameter name for the membership provider ? AS I want to substitute it with the session name.
Thanks
anas
All-Star
73431 Points
7859 Posts
Moderator
Re: What parameter to use in an Objectdatasource ?
Dec 20, 2008 12:18 PM|LINK
Hi
You can handle the Selecting event of the object data source ,
Protected Sub ObjectDataSource1_Selecting(ByVal sender As System.Object, ByVal e As System.Web.UI.WebControls.ObjectDataSourceSelectingEventArgs) Handles ObjectDataSource1.Selecting e.InputParameters("username") = Page.User.Identity.Name End SubBut you need to use <asp:Paramter instead of the Session Parameter.
The other way is to create a custom Paratemer that can read the username automatically ,
Take a look at my blog post here
afrika
Member
249 Points
860 Posts
Re: What parameter to use in an Objectdatasource ?
Dec 20, 2008 08:35 PM|LINK
WORKED. Thanks a great deal