Asp.net Dropdownlist in data grid view?

y0ger_19

New member
I'm making a drop down list in a data grid view, I was able to get to the part of making the drop down list but I reached a road block on the selected item and saving the entry in the database. Here is my code

<asp:TemplateField HeaderText="Visible" SortExpression="pVisible">
<EditItemTemplate>
<asp:DropDownList ID="DropDownList3" runat="server" Height="64px"
Width="184px" Text='<%# Bind("pVisible") %>'>
<asp:ListItem>True</asp:ListItem>
<asp:ListItem>False</asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label4" runat="server" Text='<%# Bind("pVisible") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>

This has an error of:

'DropDownList3' has a SelectedValue which is invalid because it does not exist in the list of items.
Parameter name: value

This appears when the edit button is pressed

If I take out:

Text='<%# Bind("pVisible") %>'

it would not result to the error page but would not update the field when the update button is pressed
 
Back
Top