EditItemTemplate - SelectedIndex

  • Thread starter Thread starter Krish
  • Start date Start date
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
 
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
 
Back
Top