waw666
waw666

Reputation: 24

devexpress how can add data in first row or add data to specific row

I used devexpress gridControl, how can I fill first row in gridControl by code or defult value , then Fill out the other rows by datatable? or how can add data to specific row. i try code but the new row go to last grid control. see this link : https://c.top4top.io/p_1697xbv9x1.png

string sql = "select sup_action_date , sup_action_code , from Suppliers_Action where supplier_id = " + txt_suppler_id.Text + "  Order by sup_action_date";

        SqlDataAdapter da = new SqlDataAdapter(sql, DB.conn);
        DataSet ds = new DataSet();
        da.Fill(ds);
        DataTable dt = ds.Tables[0];

        BindingSource dtbinding = new BindingSource();
        dtbinding.DataSource = dt;

        gridcontroltest.DataSource = dtbinding;
        gridviewtest.AddNewRow();
        gridviewtest.SetRowCellValue(GridControl.NewItemRowHandle, "Column Name", "test");

Upvotes: 0

Views: 822

Answers (1)

waw666
waw666

Reputation: 24

DataTable dt = gridControl1.DataSource as DataTable;
DataRow row = dt.NewRow();
row["fieldname"] = 11;
row["fieldname"] = "test";
dt.Rows.InsertAt(row, 0);

gridControl1.DataSource = dt;

Upvotes: 0

Related Questions