How to show get selected data into form when double click on GridView

I'm using Devexpress GridControl to show Employee Data from database,

here Employee Form

private void Employee_Load(object sender, EventArgs e)
        {
            String strProvider = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source= C:UsersJohnDocumentsSistem Informasi Akuntansi.accdb";
            string query = "SELECT EmployeeCode, FirstName, LastName, FullName, JoinDate, EffectiveDate, Address, PhoneNumber, DateofBirth, PlaceofBirth, Email, Gender, Religion, Nationality FROM Employee";
            OleDbConnection con = new OleDbConnection(strProvider);
            OleDbCommand cmd = new OleDbCommand(query, con);
            con.Open();
            cmd.CommandType = CommandType.Text;
            OleDbDataAdapter da = new OleDbDataAdapter(cmd);
            DataTable employee = new DataTable();
            da.Fill(employee);
            view_employee.DataSource = employee;

        }

It will show as preview below 在这里输入图像描述

When I double click in any row I want to make it show A Form with the data I select, here is my DoubleClick event

private void gridView1_DoubleClick(object sender, EventArgs e)
    {
        edit_employee editdata = new edit_employee();
        editdata.ShowDialog();

and here my edit_employee Form

private void edit_employee_Load(object sender, EventArgs e)
    {
        OleDbCommand command = new OleDbCommand("SELECT EmployeeCode, FirstName, LastName, FullName, JoinDate, EffectiveDate, Address, PhoneNumber, DateofBirth, PlaceofBirth, Email, Gender, Religion, Nationality FROM Employee WHERE Employee.Id = 57"); //must use parameter
        command.Connection = connection;
        OleDbDataReader dr = null;
        connection.Open();
        dr = command.ExecuteReader();
        while (dr.Read())
        {
            employee_code.Text = (dr["EmployeeCode"].ToString());
            txtfirstname.Text = (dr["FirstName"].ToString());
            txtlastname.Text = (dr["LastName"].ToString());
            txtfullname.Text = (dr["FullName"].ToString());
            joindate.Text = (dr["JoinDate"].ToString());
            effectivedate.Text = (dr["EffectiveDate"].ToString());
            address.Text = (dr["Address"].ToString());
            phonenumber.Text = (dr["PhoneNumber"].ToString());
            dateofbirth.Text = (dr["DateofBirth"].ToString());
            placeofbirth.Text = (dr["PlaceofBirth"].ToString());
            email.Text = (dr["Email"].ToString());
            gender.Text = (dr["Gender"].ToString());
            religion.Text = (dr["Religion"].ToString());
            nationality.Text = (dr["Nationality"].ToString());
        }
        connection.Close();
    }

This Form below will show after I DoubleClick any row

在这里输入图像描述

because I filter the data with query "WHERE Employee.Id = 57" I know to show the form with the data I clicked, I shouldn't filter like that (must filter using Parameter) but I don't know how to filter the Parameter from the row I selected.

Any Solution would be very appreciated.

链接地址: http://www.djcxy.com/p/31058.html

上一篇: 如何在DevExtreme数据网格的headerFilter中对过滤器项进行排序?

下一篇: 双击GridView时如何显示将所选数据显示到表单中