啊,感谢里卡多。这是有道理的,但我仍然无法实现它的工作。我想我忘了提及控制是在一个界限内,如果这有所作为。
这里的炫魅代码:
<div align="center">
<asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False"
DataKeyNames="RegistrationID" DataSourceID="SqlDataSourceFBReg"
DefaultMode="Insert" Height="50px"
Width="55%" OnItemInserted="NFLElim" >
<Fields>
<asp:BoundField DataField="RegistrationID" HeaderText="RegistrationID"
InsertVisible="False" ReadOnly="True" SortExpression="RegistrationID" />
<asp:BoundField DataField="UserName" HeaderText="One Season User Name"
SortExpression="UserName" />
<asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" />...
而这里的我怎么也背后设置代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class NFLElim_Reg : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
DetailsView1.DefaultMode = DetailsViewMode.Insert;
if (DetailsView1.FindControl("UserName") != null)
{
TextBox txt1 = (TextBox)DetailsView1.FindControl("UserName");
txt1.Text = User.Identity.Name.ToString();
}
}
}
protected void NFLElim(object sender, DetailsViewInsertedEventArgs e)
{
Response.Redirect("Account.aspx");
}
}
希望我插入的代码正确
一些代码将有助于我们理解你的问题好一点。 – Phaedrus 2009-10-01 00:46:49