Intersoft Support Center

Integrate WebInput to FormView

You can integrate WebInput to FormView.

In this topic, you will learn how to integrate WebInput to FormView.

To integrate WebInput to FormView

  1. In FormView1_ItemCreated event handler function, put the following code:
    C# Copy ImageCopy Code
    protected void FormView1_ItemCreated(object sender, EventArgs e)
    {
       if(FormView1.Row.RowState == DataControlRowState.Edit)
       {
          DataRowView rowView = FormView1.DataItem as DataRowView;
            
          if(rowView != null)
          {
             WebInput wiBirthDate = FormView1.FindControl("wiBirthDate") as WebInput;
    
             if(wiBirthDate != null)
                wiBirthDate.Value = (DateTime) rowView["BirthDate"];
    
             WebInput wiHireDate = FormView1.FindControl("wiHireDate") as WebInput;
    
             if (wiHireDate != null)
                wiHireDate.Value = (DateTime) rowView["HireDate"];
    
             WebInput wiHomePhone = FormView1.FindControl("wiHomePhone") as WebInput;
       
             if (wiHomePhone != null)
                wiHomePhone.Value = rowView["HomePhone"] as string;
       
             WebInput wiExtension = FormView1.FindControl("wiExtension") as WebInput;
       
             if (wiExtension != null)
                wiExtension.Value = rowView["Extension"] as string;
          }
       }
    }
    

  2. In FormView1_ItemUpdating event handler function, put the following code:
    C# Copy ImageCopy Code
    protected void FormView1_ItemUpdating(object sender, FormViewUpdateEventArgs e)
    {
       WebInput wiBirthDate = FormView1.FindControl("wiBirthDate") as WebInput;
       e.NewValues.Add("BirthDate", wiBirthDate.Value);
    
       WebInput wiHireDate = FormView1.FindControl("wiHireDate") as WebInput;
       e.NewValues.Add("HireDate", wiHireDate.Value);
       
       WebInput wiHomePhone = FormView1.FindControl("wiHomePhone") as WebInput;
       e.NewValues.Add("HomePhone", wiHomePhone.Text);
       
       WebInput wiExtension = FormView1.FindControl("wiExtension") as WebInput;
       e.NewValues.Add("Extension", wiExtension.Text);
    }
    
Previous Next