I just want to insert some data from a datatable to a list.
Here is my class:
class WhereColumnValue
{
private string columnName;
public string _columnName
{
get { return columnName; }
set { columnName = value; }
}
private string setValue;
public string _setValue
{
get { return setValue; }
set { setValue = value; }
}
private bool setValueStatus;
public bool _setValueStatus
{
get { return setValueStatus; }
set { setValueStatus = value; }
}
}
Now i have a list of WhereColumnValue type.
List<WhereColumnValue> lstWhereColumnValue = new List<WhereColumnValue>();
How could I insert data to this lstWhereColumnValue?
I have tried following code:
foreach (DataRow tmp in dtAllColumnData.Rows)
{
lstColumn.Add(tmp["COLUMN_NAME"].ToString());
lbTableColumns.Items.Add(tmp["COLUMN_NAME"]);
lstWhereColumnValue.Add(***);
}
I have to add an item here(*). but i only have value for _columnValue. Rest two will remain null. how would i do this?
You need to instantiate your class and add filled-out instances of it to your list. Something like this:
You may also want to follow naming conventions and have your properties be ColumnName, SetValue, etc.