david7777
03-18-2003, 12:30 PM
I have a datagrid called searchGrid
I have data bound it with a filled dataset. Everything worls fine, but i need a condition in there...
I have something like this:
<asp:DataGrid id="SearchGrid" runat="server" AutoGenerateColumns="false" PageSize="5" AllowPaging="true">
<Columns>
<asp:BoundColumn DataField="id" Visible="False" />
<asp:TemplateColumn>
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem, "short_desc") %>
<br />
<% if (DataBinder.Eval(Container.DataItem, "discount")) > 0 then %>
Was R <%# DataBinder.Eval(Container.DataItem, "price") %>
<br />
Now R <%# get_Price_After_Discount(DataBinder.Eval(Container.DataItem, "price"), DataBinder.Eval(Container.DataItem, "discount")) %>
<br />
<% else %>
R <%# DataBinder.Eval(Container.DataItem, "price") %>
<br />
<% end if %>
<asp:Button Text="Add To Cart" runat="Server" />
<br />
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>
The if part:
<% if (DataBinder.Eval(Container.DataItem, "discount")) > 0 then %>
Was R <%# DataBinder.Eval(Container.DataItem, "price") %>
<br />
Now R <%# get_Price_After_Discount(DataBinder.Eval(Container.DataItem, "price"), DataBinder.Eval(Container.DataItem, "discount")) %>
<br />
<% else %>
R <%# DataBinder.Eval(Container.DataItem, "price") %>
<br />
<% end if %>
does not work. Why not? I get the error:
Name 'Container' is not declared.
<%# DataBinder.Eval(Container.DataItem, "price") %> works, but <% if (DataBinder.Eval(Container.DataItem, "discount")) > 0 then %> does not.
How do I access the information from the datagrid for use in an if statement? Or is there a better way?
I have data bound it with a filled dataset. Everything worls fine, but i need a condition in there...
I have something like this:
<asp:DataGrid id="SearchGrid" runat="server" AutoGenerateColumns="false" PageSize="5" AllowPaging="true">
<Columns>
<asp:BoundColumn DataField="id" Visible="False" />
<asp:TemplateColumn>
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem, "short_desc") %>
<br />
<% if (DataBinder.Eval(Container.DataItem, "discount")) > 0 then %>
Was R <%# DataBinder.Eval(Container.DataItem, "price") %>
<br />
Now R <%# get_Price_After_Discount(DataBinder.Eval(Container.DataItem, "price"), DataBinder.Eval(Container.DataItem, "discount")) %>
<br />
<% else %>
R <%# DataBinder.Eval(Container.DataItem, "price") %>
<br />
<% end if %>
<asp:Button Text="Add To Cart" runat="Server" />
<br />
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>
The if part:
<% if (DataBinder.Eval(Container.DataItem, "discount")) > 0 then %>
Was R <%# DataBinder.Eval(Container.DataItem, "price") %>
<br />
Now R <%# get_Price_After_Discount(DataBinder.Eval(Container.DataItem, "price"), DataBinder.Eval(Container.DataItem, "discount")) %>
<br />
<% else %>
R <%# DataBinder.Eval(Container.DataItem, "price") %>
<br />
<% end if %>
does not work. Why not? I get the error:
Name 'Container' is not declared.
<%# DataBinder.Eval(Container.DataItem, "price") %> works, but <% if (DataBinder.Eval(Container.DataItem, "discount")) > 0 then %> does not.
How do I access the information from the datagrid for use in an if statement? Or is there a better way?