使用 User.Identity.Name 值预填充详细信息视图插入项模板文本框



我正在尝试将经过身份验证的用户的用户名放在插入项模板上。我需要最简单的解释,因为我是新手。我非常感谢您的帮助。这是我所拥有的:

    <InsertItemTemplate>
         <asp:LoginName ID="LoginName2" runat="server" User.Identity.Name='<%# Bind("UserName") %>'/>
    </InsertItemTemplate>

谢谢

何塞

从代码隐藏中执行此操作

<asp:DetailsView ID="DetailsView1" runat="server" OnDataBound="DetailsView1_DataBinding">
<InsertItemTemplate>
     <asp:LoginName ID="LoginName2" runat="server" />
</InsertItemTemplate>    
</asp:DetailsView>

Protected Sub DetailsView1_DataBinding(ByVal sender As Object, ByVal e As System.EventArgs) Handles DetailsView1.DataBinding
LoginName2.text =User.Identity.Name
End Sub

最新更新