J
James Zhuo
Accessing Items in a Collection works with the [] as suggested by Kevin and
Chris (thx)
But when i tried to use the same technic with databinding within the aspx
file, it doesn't seem to work.
This is the aspx part that i am talking about
<aspataGrid id="dgThreads" runat="server" AutoGenerateColumns="False">
<Columns>
<asp:TemplateColumn HeaderText="Databases">
<ItemTemplate>
<%# Container.DataItem["author_id"] %>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</aspataGrid>
Compiler Error Message: CS0021: Cannot apply indexing with [] to an
expression of type 'object'
I've tried to look up what functions and properties that are available with
DataItem with no success.
Alternatively i could have changed the TemplateColumn to a BoundColumn and
simply specify the datafield I want, this approach works, but this lacks
flexibility when i want to create customized columns. So What i want to do
is know how I can bind data explicitly to a TemplateColumn explicitly using
<%# ......................%>
Please help again.
Cheers
j
Chris (thx)
But when i tried to use the same technic with databinding within the aspx
file, it doesn't seem to work.
This is the aspx part that i am talking about
<aspataGrid id="dgThreads" runat="server" AutoGenerateColumns="False">
<Columns>
<asp:TemplateColumn HeaderText="Databases">
<ItemTemplate>
<%# Container.DataItem["author_id"] %>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</aspataGrid>
Compiler Error Message: CS0021: Cannot apply indexing with [] to an
expression of type 'object'
I've tried to look up what functions and properties that are available with
DataItem with no success.
Alternatively i could have changed the TemplateColumn to a BoundColumn and
simply specify the datafield I want, this approach works, but this lacks
flexibility when i want to create customized columns. So What i want to do
is know how I can bind data explicitly to a TemplateColumn explicitly using
<%# ......................%>
Please help again.
Cheers
j