您好我需要在DropDownList中顯示屬於特定ROLE的「用戶」列表。GetUsersInRole DataSource爲DropDownList
這是我的代碼:
// Find DropDownList
DropDownList myUserList = (DropDownList)uxInsertAuthorInput.FindControl("uxUserListSelector");
// Bind data to DropDownList
myUserList.DataSource = Roles.GetUsersInRole("CMS-AUTHOR");
myUserList.DataBind();
myUserList.DataTextField = "UserName";
我的問題是當訪問者選擇DropDownList中的一個項目。 傳遞的實際值是「UserName」而不是「UserId」。
當訪問者從DropDownList中選擇一個項目時,我需要使用「UserId」值。
怎麼辦? 感謝您的幫助
這是正確的答案,雖然我會使用'Membership.GetUser(用戶名)y'而不是Membership.FindUsersByName,並找到所選項目的Id。 – Greg 2010-11-22 16:09:35
@Greg,謝謝,更新了您的建議。 – 2010-11-22 17:04:05
我同意使用Membership.GetUser(用戶名) – GibboK 2010-11-23 07:12:24