In this example snippet, i am going to show how to get values from a FormView Control and also assign new values to a field. This is a raw snippet, so if you are searching for an idea to insert or update a value in form view iteminserting event this will help for a beginner. This is not a full tutorial.

In this snippet, fictitiously i am going to catch title value and generate its slug and also add inserted date to a record in the table. To get the title value it is important that i check for the formview currentmode.

protected void FormView1_ItemInserting(object sender, FormViewInsertEventArgs e)
string titleslug="";

if (FormView1.CurrentMode == FormViewMode.Insert)
titleslug = ((TextBox)FormView1.FindControl("titleTextBox")).Text;

titleslug = ""; // Your Slug generation function or codes here;

e.Values["TitleSlug"] = titleslug;
e.Values["InsertedDate"] = DateTime.UtcNow;


The same idea can be used in FormView.ItemUpdating Event but when you check for the mode it should be FormViewMode.Edit and e.values should e.NewValues