why GetDataRow returned null ?!
i gave gridcontrol datasource bindingData why it's returned null ?!!
HELP

why GetDataRow returned null ?!
i gave gridcontrol datasource bindingData why it's returned null ?!!
HELP

Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Tahir AnsariRank #366 · 6.8K reputationPosted Jul 21, 2024, 9:47 AM EDT
Hi Mohammad,
i think the specific row handle might not map to a data row, resulting in a null return value.
please try below code
private void from_Analysis_Load(object sender, EventArgs e) { var db = new DAL.dbDataContext(); var query = (from anaSheet in db.AnalysisSheets select new DB { ID = anaSheet.ID, Name = anaSheet.Name, Price = anaSheet.Price }).ToList(); gridControl1.DataSource = query; Master.gridViewColumnsColor(gridView1, gridControl1); gridView1.DoubleClick += GridView1_DoubleClick; } private void GridView1_DoubleClick(object sender, EventArgs e) { foreach (int rowHandle in gridView1.GetSelectedRows()) { if (rowHandle = gridView1.DataRowCount) { continue; // Skip invalid row handles } DataRow row = gridView1.GetDataRow(rowHandle); if (row == null) { continue; // Skip null rows } // Proceed with valid, non-null rows gridView2.AddNewRow(); int newRowHandle = gridView2.GetDataSourceRowIndex(gridView2.DataRowCount); gridView2.SetRowCellValue(newRowHandle, "ID", row["ID"]); gridView1.DeleteRow(rowHandle); } }Accept the answer if it resolves your issue.