Data Grid Template Columns at Run Time

Discussion in 'ASP .Net Web Controls' started by Mark, Sep 25, 2003.

  1. Mark

    Mark Guest

    Hi
    Suppose I have a data grid set up using HTML containing
    templated columns.

    <asp:TemplateColumn HeaderText="SMILES (Template)">
    <ItemTemplate>
    <asp:textbox runat="server" Text='<%# DataBinder.Eval
    (Container, "DataItem.ISOSMILES") %>'></asp:textbox>
    </ItemTemplate>
    </asp:TemplateColumn>

    At run time, a sub gets passed this data grid and wants to
    work out the item template in each column. Specifically,
    I need to work out which SQL column (ISOSMILES in the
    example above) the column is going to try and bind to, if
    any.

    The reason is I want to remove the column from the data
    grid if the particular query I am going to run will not
    return that column, so as to avoid an exception.

    With a bound column, you get the Datafield property. With
    a templated column, I cannot figure out how to access the
    ItemTemplate, as all this returns is the ITemplate
    interface, which has no useful properties.

    Thanks for any suggestions.

    Mark
     
    Mark, Sep 25, 2003
    #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. Matthew Louden
    Replies:
    0
    Views:
    381
    Matthew Louden
    Nov 18, 2003
  2. =?Utf-8?B?U2ltb24=?=

    Problems with dynamic template columns in a data grid

    =?Utf-8?B?U2ltb24=?=, Oct 7, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    1,129
    rizwan328
    Nov 22, 2007
  3. =?Utf-8?B?cG11ZA==?=
    Replies:
    2
    Views:
    1,009
    =?Utf-8?B?cG11ZA==?=
    Jan 10, 2005
  4. Pierre Yves
    Replies:
    2
    Views:
    526
    Pierre Yves
    Jan 10, 2008
  5. Ahmet Gunes

    How to add columns to a grid dynamically at run time?

    Ahmet Gunes, Sep 15, 2003, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    221
    Ravikanth[MVP]
    Sep 15, 2003
Loading...

Share This Page