Using the #Bind method in a GridView

  • Thread starter Thread starter Mark B
  • Start date Start date
M

Mark B

I've got a GridView that has a SQL backend to a table tblLanguageValues.

When a user is adding non-US language values (after selecting a LanguageCode
from a drop-down, e.g. fr-CA), I hide the Platform drop-down box which is in
a GridView row since it's superfluous as in other places I just go by what
the EN-US value says.

<asp:DropDownList ID="DropDownList2" runat="server" Text='<%#
Bind("Platform") %>'>
<asp:ListItem>XP</asp:ListItem>
<asp:ListItem>2000</asp:ListItem>
</asp:DropDownList>

When trying to edit a non EN-US row in the GridView, I get an error message:

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



How can I programmatically refrain from Binding the Platform field when
LanguageCode<>'EN-US'?
 
Hello Mark,

Check those solution
1) http://blog.evonet.com.au/post/2008...e-it-does-not-exist-in-the-list-of-items.aspx
2) http://www.chrismay.org/2006/05/07/...e+It+Does+Not+Exist+In+The+List+Of+Items.aspx

---
WBR,
Michael Nemtsev [Microsoft MVP] :: blog: http://msmvps.org/blogs/laflour
:: http://twitter.com/laflour

"Tis nothing good or bad, but thinking makes it so" (c) W.Shakespeare


MB> I've got a GridView that has a SQL backend to a table
MB> tblLanguageValues.
MB>
MB> When a user is adding non-US language values (after selecting a
MB> LanguageCode from a drop-down, e.g. fr-CA), I hide the Platform
MB> drop-down box which is in a GridView row since it's superfluous as
MB> in other places I just go by what the EN-US value says.
MB>
MB> <asp:DropDownList ID="DropDownList2" runat="server" Text='<%#
MB> Bind("Platform") %>'>
MB> <asp:ListItem>XP</asp:ListItem>
MB> <asp:ListItem>2000</asp:ListItem>
MB> </asp:DropDownList>
MB> When trying to edit a non EN-US row in the GridView, I get an error
MB> message:
MB>
MB> 'DropDownList2' has a SelectedValue which is invalid because it does
MB> not
MB> exist in the list of items.
MB> Parameter name: value
MB> How can I programmatically refrain from Binding the Platform field
MB> when LanguageCode<>'EN-US'?
MB>
 
Back
Top