public void ShowInGrid(DataGridView dgv) { List <DiseaseDetails> lst = new List <DiseaseDetails>(); MedDbEntities db = new MedDbEntities(); foreach (Disease d in db.Diseases) { DiseaseDetails dd = new DiseaseDetails(); string s = getCategoryNameFromCategoryId(d.CategoryId); dd.Id = d.Id; dd.UrduName = d.UrduName; dd.EnglishName = d.EnglishName; dd.CategoryId = d.CategoryId; dd.CategoryName = s; lst.Add(dd); } dgv.DataSource = lst; }
private void Details_Load(object sender, EventArgs e) { // TODO: This line of code loads data into the 'medDbDataSet4.Disease' table. You can move, or remove it, as needed. this.diseaseTableAdapter.Fill(this.medDbDataSet4.Disease); // TODO: This line of code loads data into the 'medDbDataSet4.Category' table. You can move, or remove it, as needed. this.categoryTableAdapter.Fill(this.medDbDataSet4.Category); DiseaseDetails d = new DiseaseDetails(); MedDbEntities db = new MedDbEntities(); //d.ShowInGrid(dgv_Details); //dgv_Details.DataSource = db.Diseases.ToList(); //int rows = dgv_Details.Rows.Count; //for (int i = 0; i < rows; i++) //{ // if (dgv_Details.Rows[i].Cells[6].FormattedValue.ToString() != "") // { // dgv_Details.Rows[i].Cells[7].Value = d.getCategoryNameFromCategoryId(Convert.ToInt32(dgv_Details.Rows[i].Cells[6].FormattedValue.ToString())); // } //} }