setting SelectedIndex in DropDownList

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.
 
C

Cor Ligthert

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top