473,397 Members | 1,974 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

How can i bind Profile.property to datalist label?

lightwalker19
i have the property UserName and FullName. i am already returning The username like

Expand|Select|Wrap|Line Numbers
  1.  <asp:Label ID="DeLabel" runat="server" Text='<%# Eval("De") %>' />
But what i want is something like this

Expand|Select|Wrap|Line Numbers
  1.  <asp:Label ID="DeLabel" runat="server" Text='<%# Eval(Profile.GetProfile("De").GetPropertyValue("FullName").ToString()) %>' />
But the i get the error: "DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'hello'."


how can i achieve this? is there another way?
May 2 '12 #1
1 1995
Finally the solution!

Create a helper Function(scalar)
Expand|Select|Wrap|Line Numbers
  1. CREATE FUNCTION [dbo].[GetProfilePropertyValue] (  
  2.     @PropertyName as varchar(max)
  3.     , @PropertyNamesString as varchar(max)
  4.     , @PropertyValuesString as varchar(max)) 
  5. RETURNS varchar(max)
  6. AS
  7. BEGIN
  8.     DECLARE @StartIndex int
  9.     DECLARE @EndIndex int
  10.     DECLARE @StartPos int
  11.     DECLARE @Length int
  12.  
  13.     -- First we find the starting position
  14.     Set @StartIndex = PatIndex('%' + @PropertyName + ':%', @PropertyNamesString) + LEN(RTRIM(@PropertyName)) + 3
  15.     Set @EndIndex = PatIndex('%:%', Right(@PropertyNamesString, LEN(@PropertyNamesString) - @StartIndex))
  16.     Set @StartPos = Cast(Substring(@PropertyNamesString, @StartIndex, @EndIndex) As Int)
  17.  
  18.     -- Now we need to know how long it is
  19.     Set @StartIndex = @StartIndex + @EndIndex + 1
  20.     Set @EndIndex = PatIndex('%:%', Right(@PropertyNamesString, LEN(@PropertyNamesString) - @StartIndex))
  21.     Set @Length = Cast(Substring(@PropertyNamesString, @StartIndex, @EndIndex) As int)
  22.  
  23.     -- Now we get the value we want
  24.     RETURN SUBSTRING(@PropertyValuesString, @StartPos + 1, @Length)
  25. END
Here is the sql statement

Expand|Select|Wrap|Line Numbers
  1. SELECT Wall.De, Wall.Texto, Wall.Data, dbo.GetProfilePropertyValue('FullName', aspnet_Profile.PropertyNames, aspnet_Profile.PropertyValuesString) AS Expr1, Wall.Para FROM aspnet_Users INNER JOIN aspnet_Profile ON aspnet_Users.UserId = aspnet_Profile.UserId INNER JOIN Wall ON aspnet_Users.UserName = Wall.De WHERE (Wall.Para = @para)
The parameters are
Expand|Select|Wrap|Line Numbers
  1. <asp:ProfileParameter Name="para" PropertyName="UserName" />
Thank you :)
May 2 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Henke | last post by:
Hello, I have one ImageButton controls which I initialize in Page_Load and declare on class level. ImageButton save = new ImageButton(); save.ImageUrl = "save.gif" save.Click += new...
1
by: Craig | last post by:
How do I programmatically change the text property of a label in an ItemTemplate in a datagrid? Specifically the Text property. I want to change the databinding to another column at runtime. ...
1
by: John Bailey | last post by:
Does not appear to be available in page base classes. I was intending to create a page base class to set the culture based on the profile setting, but the profile property does not apear to be...
3
by: Bob Lehmann | last post by:
Hi, I'm trying to bind an ArrayList to a DataList. I get the error DataBinder.Eval: 'System.String' does not contain a property with the name Name. I don't know what property of ArrayList...
1
by: Charlie | last post by:
Hi: Can the DataGrid or DataList be bound to a strongly typed collection? Thanks, Charlie
1
by: Trevor Bezotte | last post by:
Hi, I'm new to asp.net. I am having trouble updating and displaying a profile property through a dropdownlist. I believe the problem has something to do with autoeventwireup but I'm not sure. If...
0
by: Giorgio | last post by:
It seems that the ASP.NET Microsoft team didn't think about this!! The profilemanager class has the following methods: - DeleteInactiveProfiles. Enables you to delete all profiles older...
2
by: Dabbler | last post by:
is there an easy way to bind the value of a session variable to a textbox or label instead of setting it in code behind? Thanks much.
2
by: swapna_munukoti | last post by:
Hi all, I am new to asp.net. So, may be my question may be simple. But I am feeling hard to achieve this. I need to create a web custom label control, for which I have to assign new property...
0
by: =?Utf-8?B?Um9iZXJ0byBSYXp6YXV0aQ==?= | last post by:
I've a problem to change a profile property during button click event in a login.aspx page. I try to set profile.property = xxx but after authentication this property remain to defaultvalue by...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.