Question : Remove ListItem from RadioButtonList inside a GridView

I have a couple of RadioButtonLists inside a GridView with just Yes/No for options.
I just added them so almost all of the values in the database for the fields are NULL.
In order to keep from getting the "value does not exest" error I added a third ListItem with a value of "" but I want to remove that list item from the page.

I found the code below and converted it from C# to VB but it doesn't work in my GridView.

Inside GridView6 one of my RadioButtonLists is in this TemplateField:

                  <asp:TemplateField HeaderText="FaithBased" SortExpression="FaithBased">
                        <EditItemTemplate>
                              <asp:RadioButtonList ID="radFaithBased" runat="server" RepeatDirection="Horizontal"
                                    RepeatLayout="Flow" SelectedValue='<%# Bind("FaithBased") %>'>
                                    <asp:ListItem Value="Yes">Yes</asp:ListItem>
                                    <asp:ListItem Value="No">No</asp:ListItem>
                                    <asp:ListItem Value=""></asp:ListItem>
                              </asp:RadioButtonList>
                        </EditItemTemplate>
                        <ItemTemplate>
                              <asp:Label ID="lblFaithBased" runat="server" Text='<%# Eval("FaithBased") %>'></asp:Label>
                        </ItemTemplate>
                  </asp:TemplateField>


How to I remove the empty ListItem?
Thanks
1:
2:
3:
4:
5:
6:
7:
Protected Sub RadioButtonList_DataBound(ByVal sender As Object, ByVal e As EventArgs)
        Dim list As RadioButtonList = DirectCast(sender, RadioButtonList)
        Dim blank As ListItem = list.Items.FindByValue("")
        If blank IsNot Nothing Then
            list.Items.Remove(blank)
        End If
    End Sub
1:
2:
Oh, this does work just fine, but I'd rather remove the item:
<asp:ListItem Value="" style="display: none" />

Answer : Remove ListItem from RadioButtonList inside a GridView

try

ActiveSheet.PageSetup.PaperSize = xlPaperLegal

Thomas
Random Solutions  
 
programming4us programming4us