EditItemTemplate - SelectedIndex

K

Krish

Looks like I can just populate dropdownlist using DataView, say
TempDataView, during
my pageload and
then in the aspx file in the EditItemTemplate use something like this:

<EditItemTemplate>
<asp:DropDownList
id = "ddMajor"
runat="server"
DataSource='<%# TempDataView%>'
DataTextField="cd_major"
DataValueField="cd_major"
SelectedIndex='<%#GetMajorDesc((String)DataBinder.Eval(Container.DataItem,
"????????")) %>' />
</EditItemTemplate>

How do i set the Selected Item or index to equal the correct item for this
rows data?

Krish
 
O

Ollie Riches

You have several options for this, depending on the information you know, If
you know the value you want to select - i.e. the value of 'cd_major' then
you can use the 'SelectedValue' property of the control and set the value,
If you know the index you can use 'SelectedIndex' and if you have the
ListItem object you can use 'SelectedIndex'

HTH

Ollie Riches
 

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