public void loaddatasummary_search() { String intlotcode = lblInternalcode.Text.Trim(); MainMenu frm = new MainMenu(); //get data from table List <object[]> data = new List <object[]>(); data = frm.getsummary_grade_search(intlotcode, "tbcuttingdetails", textBox1.Text.Trim()); dataGridView2.Rows.Clear(); if (data.Count > 0) { dataGridView2.Rows.Add(data.Count); for (int i = 0; i < data.Count; i++) { dataGridView2.Rows[i].Height = 35; if (data[i][1] != null) { dataGridView2.Rows[i].Cells[0].Value = data[i][1].ToString(); } if (data[i][2] != null) { dataGridView2.Rows[i].Cells[1].Value = data[i][2].ToString(); } if (data[i][3] != null) { dataGridView2.Rows[i].Cells[2].Value = data[i][3].ToString(); } } } }