My list returns back <string, string> apparently. How can I append the second string in my KeyValuePair and add in the ID that I get back from my second database call?
// Database calls here
KeyValuePair<string, string> parks = new KeyValuePair<string, string>();
DataSet dset = new DataSet();
var list = new List<KeyValuePair<string, string>>();
list.Add(new KeyValuePair<string, string>("Select one", "0"));
foreach (DataRow row in ds.Tables[0].Rows)
{
//My database calls including:
db.AddInParameter(comm, "@pID", DBType.Int32, row[1]);
dset = db.ExecuteDataSet(comm);
string attr = dset.Tables[0].Rows[0]["Value"].ToString();
list.Add(new KeyValuePair<string, string>(row[0].ToString() + " - " + attr, row[1].ToString()));
}
return list;
in
KeyValuePair<TKey, TValue>key and value are readonly. you can useDictionary<string,string>for you work and getKeyValuePair<string, string>from it.I think this works:
for append the second string you can use
list["/*Your ID*/"]= YourData;List<KeyValuePair<TKey, TValue>>is not good way. It’s like that you use a cup of tea for offing the fire!