OK..... im just feling a bit lost with this one and it seemed like a small and simple task... but i was so wrong.
I have a datagrid which has field which is a boolean. I populate the datagrid fine, but when the user goes to edit that row in the datgrid I would like the boolean field to be shown as a radiobutton list.
So i have created two options in my radiobutton list as below:
<edititemtemplate>
<asp:RadioButtonList id="rbl1" runat="server">
<asp:ListItem Value="1">Yes</asp:ListItem>
<asp:ListItem Value="0">No</asp:ListItem>
</asp:RadioButtonList>
</edititemtemplate>
However I would like the boolean value to be represented in the radiobutton list as the slected button. So if my db has a value of one then Yes will be selected in radio button list.
So I thought I would create a function to get me the value and return a boolean value to the list item. Something like the below:
<asp:ListItem Value="1" Selected="<%#BuildRadioBtns(DataBinder.Eval(Container.DataItem, "SvpaRequired"))%>">Yes</asp:ListItem>
My function is:
Protected Function BuildRadioBtns(ByVal bln As Boolean) As Boolean
If bln = True Then
Return True
Else
Return False
End If
End Function
However this doesnt work, am i going about this the right way? I keep get the below error:
Literal content ('<asp:ListItem Value="1" Selected="') is not allowed within a 'System.Web.UI.WebControls.ListItemCollection'.
Any help would be much appreciated, thanks in advance
I have a datagrid which has field which is a boolean. I populate the datagrid fine, but when the user goes to edit that row in the datgrid I would like the boolean field to be shown as a radiobutton list.
So i have created two options in my radiobutton list as below:
<edititemtemplate>
<asp:RadioButtonList id="rbl1" runat="server">
<asp:ListItem Value="1">Yes</asp:ListItem>
<asp:ListItem Value="0">No</asp:ListItem>
</asp:RadioButtonList>
</edititemtemplate>
However I would like the boolean value to be represented in the radiobutton list as the slected button. So if my db has a value of one then Yes will be selected in radio button list.
So I thought I would create a function to get me the value and return a boolean value to the list item. Something like the below:
<asp:ListItem Value="1" Selected="<%#BuildRadioBtns(DataBinder.Eval(Container.DataItem, "SvpaRequired"))%>">Yes</asp:ListItem>
My function is:
Protected Function BuildRadioBtns(ByVal bln As Boolean) As Boolean
If bln = True Then
Return True
Else
Return False
End If
End Function
However this doesnt work, am i going about this the right way? I keep get the below error:
Literal content ('<asp:ListItem Value="1" Selected="') is not allowed within a 'System.Web.UI.WebControls.ListItemCollection'.
Any help would be much appreciated, thanks in advance