private void dgSearchItem_CellClick(object sender, DataGridViewCellEventArgs e) { try { string str = dgSearchItem.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString(); Admin Bind = new Admin(); ArrayList data_contract = Bind.BindAllItemDetails(str); if (data_contract.Count == 0) { MessageBox.Show("NO DATA MATCH WITH DATABASE RECORDS", "NO DATA FOUND", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { for (int i = 0; i < data_contract.Count; i = i + 5) { string ItemNumber = (string)data_contract[i]; string ItemName = (string)data_contract[i + 1]; string ItemDescription = (string)data_contract[i + 2]; string ItemCategory = (string)data_contract[i + 3]; Int64 ItemStock = (Int64)data_contract[i + 4]; tbSearchItemNumber.Text = ItemNumber; tbSearchItemName.Text = ItemName; tbSearchItemDescription.Text = ItemDescription; tbSearchItemCategory.Text = ItemCategory; tbSearchItemStock.Text = ItemStock.ToString(); } } } catch (SqlException) { MessageBox.Show("MICROSOFT SQL SERVER DATABASE ERROR!", "ERROR OCCURS", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (InvalidOperationException) { MessageBox.Show("INVALID OPERATION!", "ERROR OCCURS", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception ex) { MessageBox.Show(ex.ToString(), "ERROR OCCURS", MessageBoxButtons.OK, MessageBoxIcon.Error); } }