Intersoft Support Center

Integrate with FormView

WebCombo is already compatible with the standard infrastructure Microsoft's FormView EditTemplate. 

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

To integrate WebCombo to FormView

  1. Drag and drop FormView control to the WebForm.
  2. Bind it to Customers table.
  3. Right click on FormView and choose EditTemplate, EditItemTemplate.
  4. Drag and drop a WebCombo control to ContactName cell in FormView EditTemplate.
  5. Bind WebCombo to AccessDataSource with DisplayMember and ValueMember to ContactName.
  6. Add an event to FormView control called FormView1_ItemCreated and 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)
          {
             string contactName = rowView.Row.ItemArray[2] as string;
             WebCombo combo = FormView1.FindControl("WebCombo1") as WebCombo;
             combo.Value = contactName;
          }
       }
    }                       
    

  7. Add an event to FormView control called FormView1_ItemUpdating and put the following code:

    C# Copy Code
    protected void FormView1_ItemUpdating(object sender, FormViewUpdateEventArgs e)
    {
       WebCombo combo = FormView1.FindControl("WebCombo1") as WebCombo;
       e.NewValues.Add("ContactName", combo.Text);
       ClientScript.RegisterClientScriptBlock(
            typeof(Page), "result", 
            "<script language='JScript'>alert('Your selection is: " + combo.Text + "');</script>");
    }
    
Previous Next