c# - Inserting using FormView -


I am trying to insert an item using a basic formio control.

I'm new to C # and control it, so bear with me FormView standard entries such as:

  item name item value item code   

There are controls that will be hidden from the user such as: I

  Protected Zero InsertButton_Click (Object Sender, EventArgs e) {LinkButton btnInsert = (LinkButton) FormView1.FindControl ("InsertButton"); Text box txtDateAdded = (Textbox) FormView1.FindControl ("ItemDateAddedTextBox"); Text box txtDateChanged = (text box) FormView1.FindControl ("ItemDateChangedTextBox"); Text box txtChangedBy = (Textbox) FormView1.FindControl ("ItemChangedByTextBox"); TxtDateAdded.Text = DateTime.Now.ToString ("MMMM DD, yyyy"); TxtDateChanged.Text = DateTime.Now.ToString ("MMMM dd, yyyy"); . TxtChangedBy.Text = HttpContext.Current.Request.ServerVariables ["AUTH_USER"] ToString (); TblItems.Insert (); }   

This indicates that the ItemName field is a tap, and throws an error, even if I can clearly see that the text is being set in the text box. Why this value is being thrown in the form of a tap? Do I need to manually create INSERT statements before calling Insert ()? How do I go about doing that?

"itemprop =" text ">

Your .aspx code is hard to tell without confirming it, but the name of the item is the code given by you The sample was not included in. It seems that your data binding syntax may not be correct, then the value in the text box on your page is not being correctly mapped to the parameter in its insert command.

Besides, what you probably want to do instead is to tie in the insert event to your data source from the hidden textbox controls. In this example, imagine you have a SQLDataSource control According to your specific data source, change:

  Private Zero On_Inserting (Object Sender, SqlDataSourceCommandEventArgs e) {e.Command.Parameters.Add (New SqlParameter ("ItemDettedTextbox", Datetime. Now.ToString ("MMMM dd, yyyy"))); ...}   

You attach your handler to your .spx page in the definition of your data source. In the design view of your webpage, click on the data source and in the Properties window, click on the Events tab, if you double click the insert event, then it should make the handler for you in your codebehind, and you just fill in your implementation.

Comments