In the below I get the error
Compiler Error Message: CS0117: 'System.Web.UI.WebControls.ListItem' does
not contain a definition for 'DataBinding'
<asp:TemplateColumn HeaderText="Ver">
<HeaderStyle HorizontalAlign="Center" Width="50px"></HeaderStyle>
<ItemStyle HorizontalAlign="Center"></ItemStyle>
<ItemTemplate>
<asp:Label id=lblVersion runat="server" Text='<%# DataBinder.Eval(Container,
"DataItem.Version") %>'>
</asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList id="ddlVersion" runat="server">
<asp:ListItem Value="2.2">2.2</asp:ListItem>
<asp:ListItem Value="3.0" Selected="<%# IsThree(3)% >3.0</asp:ListItem>
<--- ERROR LINE
</asp:DropDownList>
</EditItemTemplate>
</asp:TemplateColumn>
public bool IsThree(int intNumber)
{
if (intNumber == 3)
return true;
else
return false;
}
Any thoughts?
Thanks,
Ron
I see only one " in the selected attribute, remove it and see what happen
Cheers,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Ronald S. Cook" <rsc...@westinis.com> wrote in message
news:%23E992Fb...@TK2MSFTNGP10.phx.gbl...
"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us> wrote
in message news:uD$QUSbkD...@TK2MSFTNGP10.phx.gbl...
It seems that you cannot use DataBinding with a ListItem , if you see the
MSDN ListItem derived directly from System.Object in order to be bindable
you need to derived from WebControl or implement the IDataBindingAccessor ,
its this latter interface which define the DataBindings property ( the
source of the error)
Solution:
1- Inherit from ListItem and implement IDataBindingAccessor interface
2- Do it by code, iterate in the DropDownList.Items collection and set the
correct DropDownList.SelectedIndex
I would go for the second one.
Hope this help,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Ronald S. Cook" <rsc...@westinis.com> wrote in message
news:%23QHlZsb...@tk2msftngp13.phx.gbl...
<asp:Label id=lblVersion runat="server" Text='<%# DataBinder.Eval(Container,
"DataItem.Version") %>'>
Your DataBinder syntax is incorrect. It should be
<asp:Label id="lblVersion" runat="server "Text='<%#
DataBinder.Eval(Container.DataItem, "Whatever") %>' />
Specifically, note the change from
DataBinder.Eval(Container, "DataItem.Version")
TO
DataBinder.Eval(Container.DataItem, "Whatever")
"Ronald S. Cook" <rsc...@westinis.com> wrote in message
news:%23E992Fb...@TK2MSFTNGP10.phx.gbl...
Yes, that's another error but no the one that he is getting, the thing is
that you cannot use databinding with a ListItem element.
Cheers,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Steven" <msgr...@berkovitz.org> wrote in message
news:uzRV2rgk...@TK2MSFTNGP09.phx.gbl...