I got this in another post
<asp:RadioButtonList runat=server ID="rd" SelectedValue='<%# Bind("sex").GetType() == typeof(DBNull) ? null : Bind("sex") %>'
<asp:ListItem Text="male" Value="1"></asp:ListItem>
<asp:ListItem Text="female" Value="2"></asp:ListItem>
</asp:RadioButtonList>
Is this a correct syntax?? If yes can someone please give the VB version of it??
SelectedValue='<%# Bind("sex").GetType() == typeof(DBNull) ? null : Bind("sex") %>'
Thanks
EDIT:
Here’s the link to that post: https://stackoverflow.com/a/5765930/713847
I’m fairly sure that this won’t work, the correct translation is:
If(TypeOf Bind("sex") Is DBNull, Nothing, Bind("sex"))Why not doing it in a readable way in codebehind?
Edit: You’ve commented that it’s inside a
FormView. I’ll show you how to do it in theDataBoundevent.