Dictionary<string,string> to Dictionary<Control,object> using IEnumerable<T>.Select()

Posted by abatishchev on Stack Overflow See other posts from Stack Overflow or by abatishchev
Published on 2010-05-13T00:01:19Z Indexed on 2010/05/13 0:04 UTC
Read the original article Hit count: 481

Filed under:
|
|
|
|

I have a System.Collections.Generic.Dictionary<string, string> containing control ID and appropriate data column to data bind:

var dic = new Dictionary<string, string>
{
    { "Label1", "FooCount" },
    { "Label2", "BarCount" }
};

I use it that way:

var row = ((DataRowView)FormView1.DataItem).Row;
Dictionary<Control, object> newOne = dic.ToDictionary(
    k => FormView1.FindControl(k.Key)),
    k => row[k.Value]);

So I'm using IEnumerable<T>.ToDictionary(Func<T>, Func<T>).

Is it possbile to do the same using IEnumerable<T>.Select(Func<T>) ?

© Stack Overflow or respective owner

Related posts about c#

Related posts about dictionary