Oh, thanks, Ricardo. It makes sense, but it's still hard for me to get it to work. I guess I forgot to mention that the control is in the border field, if that matters.
Here is the main page code:
<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" />...
And here is how I have the code behind the setup:
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"); } }
Hope I inserted the code correctly
source share