如何通过单击按钮调用多次单击

时间:2014-07-20 10:18:48

标签: .net

我的页面中有两个按钮。我希望当我点击单个按钮时,两个按钮动作都必须激活。我在这里分享我的代码

public void Button1_Click(object sender, System.EventArgs e)
{
   Insert(sender, e);
   **EmployeeFormView_ItemInserting(sender,  Insert);** 
}
    public void EmployeeFormView_ItemInserting(object sender, FormViewInsertEventArgs e)
    {


        TextBox SexTextBox = (TextBox)form1.FindControl("SexTextBox");
        TextBox dobTextBox = (TextBox)form1.FindControl("dobTextBox");
        TextBox office_addressTextBox = (TextBox)form1.FindControl("office_addressTextBox");


        SqlConnection conn = new SqlConnection(connStr);
        com.Connection = conn;
        com.CommandText = "INSERT INTO Employees Values('" + SexTextBox.Text + "','" + dobTextBox.Text + "', '" + office_addressTextBox.Text + "')";
        conn.Open();
        com.ExecuteNonQuery();
        Response.Write("Record inserted successfully");
        bindgrid();
        conn.Close();
    }
   public void Insert(object sender, EventArgs e)
    {
        //Lets validate the page first
        if (!Page.IsValid)
            return;

        int intResult = 0;
        // Page is valid, lets go ahead and insert records
        // Instantiate BAL object

        PersonBAL pBAL = new PersonBAL();
    // Instantiate the object we have to deal with
    Person person = new Person();

        // set the properties of the object
        person.a_select_part = DropDownList1.SelectedValue;
        person.a_dalal_name = TextBox2.Text;
        person.a_owner_name = TextBox3.Text;
        person.a_mobile_number = TextBox4.Text;


        try
        {
            intResult = pBAL.research(person);
            if (intResult > 0)
                TextBox1.Text = "pankil";
            else
                TextBox1.Text = "FirstName [<b>" + TextBox1.Text + "</b>] alredy exists, try another name";

        }
        catch (Exception ee)
        {
            TextBox1.Text = ee.Message.ToString();
        }
        finally
        {
            person = null;
            pBAL = null;


        }

    }

现在应该将哪些参数传递给

  

EmployeeFormView_ItemInserting(发件人,);

1 个答案:

答案 0 :(得分:0)

要通过单击一个按钮在同一页面中执行两个按钮的操作,您需要在第一个按钮中调用第二个按钮的按钮单击事件,即

this.Button2.PerformClick();