In my ASP.NET application, I have a GridView. For a particular field in this GridView, I've added an EditItemTemplate with a DropDownList. However, if the value of the field is "X", then I want to just display a label instead of the DropDownList. So how can I programatically check the field value, then decide which control to display?
Here is my EditItemTemplate:
<EditItemTemplate>
<asp:DropDownList ID="DropDownListLevel_ID" runat="server"
DataSourceID="ODSTechLvl" DataTextField="Level_Name"
DataValueField="Level_ID" SelectedValue='<%# Bind("Level_ID", "{0}") %>'>
</asp:DropDownList>
</EditItemTemplate>
If the value of Level_ID is "X", then I want to use:
<asp:Label ID="LabelLevel_ID" runat="server" Text='<%# Bind("Level_ID") %>'></asp:Label>
instead of the DropDownList.
I tried embedding an if statement before the DropDownList to check Eval("Level_ID"), but that doesn't seem to work. Any thoughts?