Please refer this code
<asp:ListBox ID="ltHospitalList" runat="server">
<asp:ListItem Text="Care Hospital" Value="Care Hospital" />
<asp:ListItem Text="Prime Hospital" Value="Prime Hospital" />
<asp:ListItem Text="Oscar Hospital" Value="Prime Hospital" />
</asp:ListBox>
<asp:Button Text="Save" runat="server" OnClick="Save" />
C#
//Check If the Item is selected or not
if (this.ltHospitalList.SelectedIndex == -1)
{
cmd.Parameters.AddWithValue("@Hospital_list", DBNull.Value);
}
//Save if the Item is Selected
else
{
cmd.Parameters.AddWithValue("@Hospital_list", this.ltHospitalList.SelectedItem.Text);
}
VB.Net
'Check If the Item is selected or not
If Me.ltHospitalList.SelectedIndex = -1 Then
cmd.Parameters.AddWithValue("@Hospital_list", DBNull.Value)
Else
'Save if the Item is Selected
cmd.Parameters.AddWithValue("@Hospital_list", Me.ltHospitalList.SelectedItem.Text)
End If