private void DataGridView2_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex > -1) { DataGridViewRow row = dataGridView2.Rows[e.RowIndex]; if ((row.Cells["Name"].Selected || row.Cells["Code"].Selected)) { int SelectedItemId = ItemMapper.SelectItemId(); if (SelectedItemId > 0) { DataTable dt = Sql.GetTable("SelectItemList", new object[] { "@ItemId", SelectedItemId }); if (dt != null && dt.Rows.Count > 0) { _handle = false; row.Cells["Name"].Value = NullCheck.IsNullString(dt.Rows[0]["Name"]); row.Cells["Code"].Value = NullCheck.IsNullString(dt.Rows[0]["Code"]); row.Cells["Barcode"].Value = NullCheck.IsNullString(dt.Rows[0]["Barcode"]); row.Cells["Description"].Value = NullCheck.IsNullString(dt.Rows[0]["Description"]); row.Cells["ItemTypeName"].Value = NullCheck.IsNullString(dt.Rows[0]["Name"]); row.Cells["NetWeight"].Value = NullCheck.IsNullString(dt.Rows[0]["NetWeight"]); row.Cells["BrutoWeight"].Value = NullCheck.IsNullString(dt.Rows[0]["BrutoWeight"]); row.Cells["UnitName"].Value = NullCheck.IsNullString(dt.Rows[0]["UnitName"]); row.Cells["Volume"].Value = NullCheck.IsNullString(dt.Rows[0]["Volume"]); row.Cells["Width"].Value = NullCheck.IsNullString(dt.Rows[0]["Width"]); row.Cells["Height"].Value = NullCheck.IsNullString(dt.Rows[0]["Height"]); row.Cells["ItemId"].Value = SelectedItemId; _handle = true; row.Cells["Name"].Selected = false; row.Cells["Code"].Selected = false; } } } } }