I have a dataset. I added a column "Tags". I need to run a function to update the value, for each row one at a time, for the "Tags" column. Here's what I've tried so far, tell me what I'm missing.
public System.Data.DataSet PopulateDataGrid(int nViewMode)
{
System.Data.DataSet ds = _data.GetGridView(nViewMode)
ds.Tables[0].Columns.Add("Tags", typeof(string));
foreach (System.Data.DataRow dr in ds.Tables[0].Rows)
{
dr.BeginEdit();
dr.ItemArray.SetValue(_dataFactory.GetPartTags(_dataFactory.ExecuteScalar("SELECT POSITION FROM PARTS WHERE PART_ID = " + dr.ItemArray.GetValue(0)).ToString()), dr.ItemArray.Length - 2);
dr.SetModified();
dr.EndEdit();
dr.AcceptChanges();
}
ds.AcceptChanges();
return ds;
}
Yeah, I know I could put using System.Data
and wouldn't have to put it in my code, but this is the only function out of many using that, so I didn't want to do that (if there's no damage to loading time, then I may). I wish I just needed to run a query and that's it, but this needs to be filled in code. If someone could help, that'd be great. Thanks.
Edit: And I've also verified that _dataFactory.GetPartTags(_dataFactory.ExecuteScalar("SELECT POSITION FROM PARTS WHERE PART_ID = " + dr.ItemArray.GetValue(0)).ToString())
returns the value I want. It just shows up blank in the DataGridView. The column is there, but nothing is populated.