user2831167
user2831167

Reputation: 177

How to pass list as parameter to a method in .aspx page

I must bind a gridview to a method which returns list<>, there are few multi select lookups in the list, for this I have a method which returns dictionary<int, string>.

In the list I have the multi select item values as {1, xyz}, {2, abc}

So I must display in the grid as xyz, abc.

For this I have written a method FormatString which is called in gridview binding.. i.e aspx page

<%# FormatString(?????????) %>

I must pass list<> in the ???? to retreive the data..

Please suggest me some solutions..

Upvotes: 0

Views: 629

Answers (2)

huMpty duMpty
huMpty duMpty

Reputation: 14460

You can try this way

Get the values to a different list from your dictionary items

var items = yourDictionary.Values.SelectMany(x => x).ToList();

Then you can simply bind the list to gridview

Upvotes: 0

Irfan TahirKheli
Irfan TahirKheli

Reputation: 3662

'<%# FormatString(Container.DataItem as YourListType) %>'

public String FormatString(YourListType listObj )
{
   //do what  you want.
}

Upvotes: 1

Related Questions