Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7776545
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T17:54:47+00:00 2026-06-01T17:54:47+00:00

I got this in another post <asp:RadioButtonList runat=server ID=rd SelectedValue='<%# Bind(sex).GetType() == typeof(DBNull) ?

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T17:54:49+00:00Added an answer on June 1, 2026 at 5:54 pm

    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?

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
            Dim sex = getSexFromStoredProcedure()
            If Not sex Is Nothing Then rd.SelectedValue = sex
        End If
    End Sub
    

    Edit: You’ve commented that it’s inside a FormView. I’ll show you how to do it in the DataBound event.

    Private Sub FormView1_DataBound(ByVal sender As Object, ByVal e As System.EventArgs) Handles FormView1.DataBound
        Select Case FormView1.CurrentMode
            Case FormViewMode.ReadOnly
                ' adjust the DataSource accordingly if its not a DataRow '
                Dim row = DirectCast(FormView1.DataItem, DataRow)
                Dim LblSex = DirectCast(FormView1.FindControl("LblSex"), Label)
                Dim sex As String = row.Field(Of String)("Sex")
                LblSex.Text = If(sex Is Nothing, "", sex)
    
            Case FormViewMode.Edit
                ' adjust the DataSource accordingly if its not a DataRow '
                Dim row As DataRow = DirectCast(FormView1.DataItem, DataRow)
                ' assuming your RadioButtonList is inside the EditItemTemplate '
                Dim RblSex = DirectCast(FormView1.FindControl("RblSex"), RadioButtonList)
                Dim sex As String = row.Field(Of String)("Sex")
                If Not sex Is Nothing Then RblSex.SelectedValue = sex
    
            Case FormViewMode.Insert
    
        End Select
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just got a fix on another post I just made but this created
I got this RegEx from another post, but it doesn't fully function like it
(I asked this question in another way , and got some interesting responses but
I got another problem, this time with tables and their borders in HTML (4.01,
I got a problem like this (this is html/css menu): Eshop | Another eshop
I've got another problem in the same code... I'm getting this error: initialization method
I've got a Perl script that needs to execute another Perl script. This second
Got this: Table a ID RelatedBs 1 NULL 2 NULL Table b AID ID
I've asked this question as a comment on another post but couldn't get it
I recently wrote another post on this same topic in which I was not

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.