What is the best way to bind a key / value pair to an asp label

I have a situation that arises in front of me very often, but now I have no solution. Suppose I have a key / value pair, such as

UserID | Username
-----------------
1 | Yogi
2 | Mike

I want to bind this data to an asp label control. Right now, what am I doing, I am binding a UserID to a label hint and a UserName to the label text. It works fine, but the disadvantage is that when the user hovers the shortcut, it shows the UserID as a hint to the user, which is obvious. I want to find a better way to do this work, please help me get a better approach here.

+5
source share
3 answers

UserID.

,

Control.Attributes["data-uid"] = UserID.ToString();
+3

ASP.Net

,

mylabel.Attributes["attributename"] = value;

WinForms/WPF

Tag. .

, , ( ) .

mylabel.Tag = value;
+4

I would use UserId as the label identifier, and for better readability I would use

Label.ID = "lblUser_" + UserId.toString();
0
source

All Articles