<asp:BoundField> can only bind to properties/fields? Not x.Item["KeyName"]?

R

Ryan Liu

Hi,

I try to use
list of XElements,
or
Array of XAttributes
or just list of Dictionary<stiring, string>

as data source to a <asp:GridView>

Then I found out I can not use <asp:BoundField> to simple display them.

Then I use Templated Fields, it works.
<SR:TemplateField HeaderText="Client"
SortExpression="Client">
<ItemTemplate>
<%# ((Dictionary<string,
string>)Container.DataItem)["Client"]%>
</ItemTemplate>
</SR:TemplateField>

I was wonder, all of above support kind of list.Item["Key"] , why not
Microsoft make it bindable? Why only limit to bind to public Property. (Here
"Client" is Dictionary entry Key, Xml Attribute name, or sub XElement
name).

Just like Javascript, we can access a.Key or a["Key"]. I think it will be
simplified things.

Or is there other better way?


Thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,817
Latest member
DicWeils

Latest Threads

Top