setting SelectedIndex in DropDownList

  • Thread starter Thread starter Maziar Aflatoun
  • Start date Start date
M

Maziar Aflatoun

Hi everyone,

I have the following code
<asp:TemplateColumn HeaderText="Administator" Visible="True"
ItemStyle-HorizontalAlign="Center">
<ItemTemplate>
<asp:Label ID="IsAdministator" Runat="server" text='<%#
FormatIsAdministator(DataBinder.Eval(Container.DataItem, "IsAdministator"))
%>'>
</asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList ID="NewIsAdministator" Runat="server"
CssClass="textbox1">
<asp:ListItem Value="0" Text="No"/>
<asp:ListItem Value="1" Text="Yes"/>
</asp:DropDownList>
</EditItemTemplate>
</asp:TemplateColumn>

Does anyone know how in EditItemTemplate I can preselect the ListItem in my
DropDownList based on what's currently in the database (0 or 1 for
NewIsAdministator dropdownlist)?

I tried: SelectedIndex = '<%# DataBinder.Eval(Container.DataItem,
"IsAdministator") %>' but that failed

Thank you
Maz.
 
Maziar,

Please do not multipost, for the one who sees this, this question is
answered by Davide Vernole in the newsgroup dotnet.general

You can crosspost that is sending one message to more newsgroups in one
time, what does not give this kind of situations, because everybody sees the
answers in all newsgroups.
Cor
 
Back
Top