<asp:GridView runat="server" ID="gridUserAccounts" SkinID="gridviewSkin" PageSize="5">
<Columns>
<asp:BoundField HeaderText="User Name" DataField="UserName" />
<asp:BoundField HeaderText="Email" SortExpression="Email" DataField="Email" />
<asp:BoundField HeaderText="Last Login Date" SortExpression="LastLoginDate" DataField="LastLoginDate" />
<asp:BoundField HeaderText="Last Activity Date" SortExpression="LastActivityDate" DataField="LastActivityDate" />
<asp:TemplateField>
<ItemTemplate>
<asp:HyperLink runat="server" NavigateUrl='<%# string.Format("manage-user-detail.aspx?UserName={0}", Eval("UserName")) %>' ID="linkNavigate" Text="View Detail" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
这背后的代码是
if (!Page.IsPostBack)
{
gridUserAccounts.DataSource = Membership.GetAllUsers();
gridUserAccounts.DataBind();
}
现在,在'manage-user-detail.aspx'页面,我正在捕获查询字符串,但它不会像这样工作
if (!IsPostBack)
{
string userKey1 = Request.QueryString["UserName"];
Guid UserID = new Guid(Membership.GetUser(userKey1).ProviderUserKey.ToString());
//Guid userKey = new Guid(userKey1);
MembershipUser mu = Membership.GetUser(UserID);
//string userName = mu.UserName;
lblKey.Text = mu.UserName;
}
标签中没有任何内容出现。为什么呢?
答案 0 :(得分:1)
我用以下代码
解决了这个问题 string userName = Membership.GetUser(Request.QueryString["UserName"].ToString()).UserName;
statusLabel.Text = userName;
答案 1 :(得分:-2)
根据我的经验,获取查询字符串的唯一方法是:
Request.QueryString.Item("UserName");
我在你的代码中看到你遗漏了Item。