public void search() { try { listToKhai = TrainFactory.SearchToKhai(txtNumberTrain.Text.Trim(), Convert.ToInt16(((ComboBoxItem)ddlTypeName.SelectedItem).Value), cbNgayDK.Checked, dtpFrom.Value, dtpTo.Value, txtSoHieuToaTau.Text.Trim()); grdTrain.AutoGenerateColumns = false; grdTrain.DataSource = listToKhai; for (var i = 0; i < grdTrain.Rows.Count; i++) { // Add to count Column grdTrain.Rows[i].Cells["Count"].Value = i + 1; } } catch (Exception ex) { if (GlobalInfo.IsDebug) { MessageBox.Show(ex.ToString()); } } }