[英]Assign Logged in User to Textbox inside a FormView Control
ASP.Net using C# I am in need of correct syntax. ASP.Net 使用 C# 我需要正确的语法。 This is critical at this point.
这在这一点上至关重要。 I need to assign the Authenticated/Logged in user to a Textbox inside a FormView control (FormView1 to be exact)!
我需要将 Authenticated/Logged in 用户分配给 FormView 控件(准确地说是 FormView1)内的文本框! I can't get this any further and I am asking for help.
我不能再进一步了,我正在寻求帮助。 I want to admit upfront that I don't have a full grasp of this and if you can help please, please provide the correct code.
我想预先承认我没有完全掌握这一点,如果您能提供帮助,请提供正确的代码。 I know what I have is wrong but I'm just showing what I am trying to do so far.
我知道我有什么错,但我只是展示我目前正在尝试做的事情。 I am doing an insert of the Form's data into a database table in SQL Server.
我正在将表单的数据插入到 SQL Server 的数据库表中。 Error message: Severity Code Description Project File Line Suppression State Error CS0103 The name 'Submitted_by_email' does not exist in the current context echodevelopment C:\\Users\\dmartin\\source\\repos\\echodevelopment\\echodevelopment\\Submitinitialrequest.aspx.cs 30 Active
错误消息:严重性代码描述项目文件行抑制状态错误 CS0103 当前上下文中不存在名称“Submitted_by_email” echodevelopment C:\\Users\\dmartin\\source\\repos\\echodevelopment\\echodevelopment\\Submitinitialrequest.aspx.cs 30 Active
protected void FormView1_DataBound(object sender, EventArgs e)
{
if (FormView1.CurrentMode == FormViewMode.Insert)
{
TextBox TGG = (TextBox)FormView1.FindControl("Submitted_by_email");
TGG.Text = Submitted_by_email.Text;
}
if (submitted_by_email != null)
{
_ = Context.User.Identity.Name;
if (User.Identity.IsAuthenticated)
submitted_by_email.Text = User.Identity.Name;
}
}
Solved!解决了!
protected void Page_Load(object sender, EventArgs e)
{
TextBox MyTextBox = (TextBox)FormView1.FindControl("TextBoxID");
MyTextBox.Text = User.Identity.Name;
}
}
} }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.