R
Ronald S. Cook
In my ASP.NET DataGrid, I would like to set the "Selected" value of a
dropdown list item depending on a condition. While this is easy to do for,
say, a textbox, .NET doesn't seem to play as nice in a dropdownlist.
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
ropDownList 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
ropDownList>
</EditItemTemplate>
</asp:TemplateColumn>
public bool IsThree(int intNumber)
{
if (intNumber == 3)
return true;
else
return false;
}
Any thoughts?
Thanks,
Ron
dropdown list item depending on a condition. While this is easy to do for,
say, a textbox, .NET doesn't seem to play as nice in a dropdownlist.
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
![Big Grin :D :D](/styles/default/custom/smilies/grin.gif)
<asp:ListItem Value="2.2">2.2</asp:ListItem>
<asp:ListItem Value="3.0" Selected="<%# IsThree(3)% >3.0</asp:ListItem>
<--- ERROR LINE
</asp
![Big Grin :D :D](/styles/default/custom/smilies/grin.gif)
</EditItemTemplate>
</asp:TemplateColumn>
public bool IsThree(int intNumber)
{
if (intNumber == 3)
return true;
else
return false;
}
Any thoughts?
Thanks,
Ron