Data Grid Template Columns at Run Time

M

Mark

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
 

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

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top