Reputation: 3180
Appologies if this has already been visited a 1,000 times over but I cant think how to word my search to get the result.
I've inherited a crappy db structure where various table use the same column names, meaning that various stored procedure return result with duplicated column names such as 'id'.
So, I've been referencing columns in my codebehind by their column number eg
reader[22].ToString();
However, I can't work out -monged head day- how to do this in the html.
For example, I have a list view and have a row with a label in it, which i would normally bind data to in a fashion such as;
<asp:Label ID="ProductLabel" Text='<%# Eval("Product") %>'runat="server" />
But, how do i do the above if I need to reference it by its column count eg column 22 ????
Thanks for any help & suggestions.
Upvotes: 2
Views: 992
Reputation: 24334
OK, my guess was close, this seems to work in a quick test:
(((YourObjectType)Container.DataItem)[0])
No eval - since that's only needed for reflecting the string to a property of your object. You might need to cast it to a string too.
Upvotes: 1