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

Discussion in 'ASP .Net' started by Ryan Liu, Feb 23, 2010.

  1. Ryan Liu

    Ryan Liu Guest

    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!
    Ryan Liu, Feb 23, 2010
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. gerinjacob
    Replies:
    0
    Views:
    424
    gerinjacob
    Sep 3, 2006
  2. Jimmy J.
    Replies:
    1
    Views:
    398
    Mark Rae
    Jan 10, 2007
  3. jobs
    Replies:
    1
    Views:
    751
    =?Utf-8?B?TWlsb3N6IFNrYWxlY2tpIFtNQ0FEXQ==?=
    Feb 10, 2007
  4. Vyacheslav Lanovets

    BoundField.HtmlEncode = false does not work

    Vyacheslav Lanovets, Aug 24, 2006, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    625
    Vyacheslav Lanovets
    Aug 24, 2006
  5. TS
    Replies:
    3
    Views:
    1,008
    Phil H
    Dec 22, 2007
Loading...

Share This Page