|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Convert a Checkbox value to text in a Formview item templateIn an Item template in a formview I have a checkbox thus:
parking: <asp:CheckBox ID="parkingCheckBox" runat="server" Checked='<%# eval("parking") %>' Enabled="false" / > However I don't want to display "parking" followed by a ticked/unticked box but rather to display "parking" (in a label?) if the check box is ticked, and not to display anything if it is unticked. How can I do this? -- Victor gadya wrote:
> In an Item template in a formview I have a checkbox thus: Maybe setup something like (in C#):> > parking: > <asp:CheckBox ID="parkingCheckBox" runat="server" Checked='<%# > eval("parking") %>' > Enabled="false" / > > > However I don't want to display "parking" followed by a ticked/unticked box > but rather to display "parking" (in a label?) if the check box is ticked, and > not to display anything if it is unticked. How can I do this? .... <ItemTemplate> <%# Eval("parking").ToString() == "1" : "parking" ? String.Empty %> </ItemTemplate> .... At least that's how I've done it with a DataGrid. Thanks a lot. I was surprised to find that the ternary operator did not exist
in vb.net and in VB the result looks like this: <%#IIf(Eval("parking") = "true", "parking </br>", String.Empty)%> -- Show quoteHide quoteVictor "Dan Christensen" wrote: > gadya wrote: > > In an Item template in a formview I have a checkbox thus: > > > > parking: > > <asp:CheckBox ID="parkingCheckBox" runat="server" Checked='<%# > > eval("parking") %>' > > Enabled="false" / > > > > > However I don't want to display "parking" followed by a ticked/unticked box > > but rather to display "parking" (in a label?) if the check box is ticked, and > > not to display anything if it is unticked. How can I do this? > > Maybe setup something like (in C#): > .... > <ItemTemplate> > <%# Eval("parking").ToString() == "1" : "parking" ? String.Empty %> > </ItemTemplate> > .... > > At least that's how I've done it with a DataGrid. > >
SelectedNode wrong when SelectedNodeChanged event fires
Dynamic ImageButton inside GridView ASP .NET Adding a second row to a datagriditem? Use dropdownlist as textbox Gridview Questions User Control Renders on Separate Line Style="text-decoration: line-through" treeview control HELP!!! DOGS IN CHINA HELP!!! DOGS IN CHINA |
|||||||||||||||||||||||