<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. Advertisements

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. moi
    Replies:
    0
    Views:
    5,931
  2. gerinjacob
    Replies:
    0
    Views:
    523
    gerinjacob
    Sep 3, 2006
  3. Replies:
    0
    Views:
    962
  4. Ryan Liu
    Replies:
    0
    Views:
    281
    Ryan Liu
    Jan 21, 2009
  5. Owen Blacker
    Replies:
    1
    Views:
    343
    Phillip Williams
    Jul 21, 2006
  6. Owen Blacker
    Replies:
    1
    Views:
    600
    Phillip Williams
    Jul 21, 2006
  7. Rudy

    why can't I only bind to one column?

    Rudy, Dec 30, 2004, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    154
  8. Phillip Williams

    Databinding methods such as Eval(), XPath(), and Bind() can only b

    Phillip Williams, May 5, 2006, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    396
    dwg1011
    May 14, 2006
Loading...