Conditional (if statement) in a datagrid

Tech-Archive recommends: Fix windows errors by optimizing your registry



Hi,

I have a datagrid and based on a condition I like to display either a
asp:textbox or asp:label. How would I do that? I have the following

<asp:TemplateColumn HeaderText="Qty">
<ItemTemplate>
<% if (DataBinder.Eval(Container.DataItem, "DynamicAttribute") = "No")
{%>

<asp:textbox id="tbxQtyNew" BackColor='<%#
SetTextBoxColor(DataBinder.Eval(Container.DataItem,
"DynamicAttribute")) %>' runat="server" text='1' />
<% } else { %>
<asp:Label id="lblQtyDisp" Text="1" runat="server"/>
<% } %> </ItemTemplate>
</asp:TemplateColumn>

Which fails. Any idea?

Thanks
Maz.

.



Relevant Pages

  • Problem with Changing text value of linkbutton
    ... <ItemTemplate> ... not,instead i should display View .How can i do that? ... I need to generate PDF stream when i click on Linkbutton in datagrid ... DMS Id and now it is working.But i need to pass DMS ID when click ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Display datagrid records
    ... May I know whether how can I display multiple picsper line in the DataGrid? ... SELECT ImageFullPath1, ImageFullPath2, ImageFullPath3 FROM MyTable ... Then you can amend the ItemTemplate like this: ...
    (microsoft.public.dotnet.framework.aspnet)
  • client side and server side with datagrid
    ... i need to display 4 different datagrids but i only have one on my aspx ... i tried to build a dynamic datagrid but couldn't find how to do ... this is the datagrid format: ... <ItemTemplate> ...
    (microsoft.public.dotnet.framework.aspnet)
  • how to enable
    ... inorder to display check boxes in datagrid, in itemtemplate i had written ... datagrid, the check box which is preseted on that row will be enabled. ...
    (microsoft.public.dotnet.framework.aspnet.webcontrols)
  • Dataset does not update the table
    ... the dataset when I display it on the datagrid. ... But all fails when it ... executes the last line....... ...
    (microsoft.public.dotnet.framework.adonet)