I'm trying to edit the data in a dataset (change the value in a column on one row), which is not linked to a database. I've been googling for about an hour with no results and no good examples out there. Hopefully someone can help me.
My table (DataTable1) has these columns - ThreadID (string, PK), StatusText (string).
I can select a row in a DataGridView, and get the ThreadID value. No matter how I've tried to edit the row in the associated dataset, either nothing happens or I get an error. Here's what I have now:
string sThreadID = "";
sThreadID = gridThreads.Rows[gridThreads.CurrentRow.Index].Cells["ID"].Value.ToString(); // gives me a good id, which is in the dataset
DataRow drRow = dataThreads.Tables["DataTable1"].Rows.Find(sThreadID);
drRow["StatusText"] = "Test";
The error I get when getting the row (3rd line) is: "Object reference not set to an instance of an object.". I can't create a new DataRow object because there's no public constructor for it (according to my research).
I'm sure I'm missing something basic, but I'm not familiar with working with datasets. What am I doing wrong? Thanks for your help.
drRow != null
? – Henk Holterman