for (i = 0; i < lpogridview.Rows.Count - 1; i++)
{
cmd.CommandText = "select lpoid, itemcode,itemname,unit,lpoqty,lporate,lpodiscount,lpovalue,nar from lpo l inner join item i on l.itemid=i.itemid where lpono='" + textBox2.Text + "'";
dr = cmd.ExecuteReader();
while (dr.Read())
lpogridview.Rows[i].Cells[0].Value = Convert.ToString(dr[0]);
lpogridview.Rows[i].Cells[1].Value = Convert.ToString(dr[1]);
lpogridview.Rows[i].Cells[2].Value = Convert.ToString(dr[2]);
lpogridview.Rows[i].Cells[3].Value = Convert.ToString(dr[3]);
lpogridview.Rows[i].Cells[4].Value = Convert.ToString(dr[4]);
lpogridview.Rows[i].Cells[5].Value = Convert.ToString(dr[5]);
lpogridview.Rows[i].Cells[6].Value = Convert.ToString(dr[6]);
lpogridview.Rows[i].Cells[7].Value = Convert.ToString(dr[7]);
}
dr.Close();