473,385 Members | 1,824 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

setting SelectedIndex in DropDownList

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.Dat aItem, "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.

Jul 21 '05 #1
1 1147
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
Jul 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: David Austin via .NET 247 | last post by:
Hello, I hope this is where I should post this. I have a problem with this code that I can't figure out...seems to be a bug in the dropdownlist control. I am trying to set multiple dropdownlists to...
5
by: Lie | last post by:
Hi all, I have problem in getting selectedindex of multiple listbox selection in a datagrid. I have a listbox with multiple selection mode inside datagrid. In Edit mode, I need to get back all...
9
by: james.e.coleman | last post by:
Hello, I have created a custom dropdownlist that is used multiple times within a single page. When trying to set the values of the controls with the page in which they are being used, they all...
4
by: Filip | last post by:
Hi all, I am having a problem with the DropDownList control consider the following code : <script language="VB" runat="server"> Sub Page_Load(S As Object, E As EventArgs) ddl.Items.Add("")...
3
by: Nathan Sokalski | last post by:
I am working on a simple user control composed of 3 DropDownLists that will be used to select Dates. The purpose of the control is to all the user to choose a date using dropdown lists but not need...
1
by: Nathan Sokalski | last post by:
I have a problem that is driving me crazy. I have a User Control composed of three DropDownLists that will be used to select a date. I have everything working except for one thing. When I select a...
6
by: Nathan Sokalski | last post by:
I am writing a User Control that uses 3 DropDownLists. When I attempt to access the SelectedIndex property it incorrectly reports the value selected by the user. Why is this? Here is my code,...
2
by: SJ | last post by:
Hi, i'm trying to use codebehind to setup my dropdowns. myWebFile.aspx has the following code : <asp:DropDownList id=test runat=server /> <asp:DropDownList id=test2 runat=server /> And...
1
by: Jason Wilson | last post by:
I have two dropdownlists that are bound to the same datasource and I have a couple of questions: 1) Because they are bound to the same datasource, I am assuming that they only make 1 round trip...
1
by: marcbb | last post by:
Hi all, I have a really strange problem working with Dropdownlists in a DataGrid. I'm trying to preselect some values from the DropDownlist for each row in the DataGrid, but it seems that...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.