I've turned on paging in my WebGrid. I've got a templated column in my grid that is used to display a hyperlink. When move to the next page, I get the following error:
Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control.
HTML: <igtbl:TemplatedColumn BaseColumnName="ID" Key="ID"> <Header Caption="ID"> </Header> <CellTemplate> <a href="WorkOrder.aspx?WorkOrderID=<%# Eval("ID") %>"><%# Eval("ID") %></a> </CellTemplate> </igtbl:TemplatedColumn>
How would one have a template column and paging work at the same time?
Rick
I have general problem with the TemplatedColumns.
Here is my markup for UltraWebGrid, I want to bind the value for the Name key into a Label and it doesn't work, it doesn't display anything.
<ig:UltraWebGrid ID="UltraWebGrid1" runat="server" DataSourceID="xmlDSAnimals" Height="200px" Width="325px"> <Bands> <ig:UltraGridBand AddButtonCaption="Animal" BaseTableName="Animal" Key="Animal"> <Columns> <ig:TemplatedColumn IsBound="True" BaseColumnName="Name" Key="Name"> <Header Caption="Name" /> <CellTemplate> <asp:Label ID="lblName" runat="server" Text='<%# Eval("Name", "Your name: {0}") %>'></asp:Label> </CellTemplate> </ig:TemplatedColumn> </Columns> </ig:UltraGridBand> </Bands> </ig:UltraWebGrid>
Hello Iva,
Thanks for writing. I guess, it really depends on the structure of your DataSource. Judging from your aspx markup, you are binding to an XmlDataSource. Could you please paste a small sample of your Xml datasource here, maybe this will provide some clues? Also, can you please try binding a standard asp:GridView control with templated columns to the same datasource and see how it goes?
I have tried something very simple (declarative flat AccessDataSource control + templated columns) and everything worked fine in my case - here is my setup:
<igtbl:UltraWebGrid ID="UltraWebGrid1" runat="server" DataSourceID="AccessDataSource1" Height="200px" Width="325px"> <Bands> <igtbl:UltraGridBand> <Columns> <igtbl:TemplatedColumn> <CellTemplate> <asp:Label ID="lblName" runat="server" Text='<%# Eval("ProductName", "Your name: {0}") %>'></asp:Label> </CellTemplate> </igtbl:TemplatedColumn> ... </Columns>...