Link to home
Start Free TrialLog in
Avatar of Angela4eva
Angela4eva

asked on

Formview dropdown help


In the below code is not working.
   SelectedValue='<%#DataBinder.Eval(Container.DataItem,"IssuanceMonth")%>'>
intelissense does not show selectedvalue, how can i populate the selected value .please help.
formview>
<ItemTemplate>
                  <td>
                                        <asp:DropDownList ID="ddlIssuanceMonth" runat="server"  Enabled="false"
                                            SelectedValue='<%#DataBinder.Eval(Container.DataItem,"IssuanceMonth")%>'>
                                        </asp:DropDownList>
                                    </td>
             

--codebehind

    protected void FVInvestigations_PreRender(object sender, EventArgs e)
    {
 DateTime month = Convert.ToDateTime("1/1/2000");
 for (int i = 0; i < 12; i++)
 {
     DateTime NextMont = month.AddMonths(i);
     ListItem list = new ListItem();
     list.Text = NextMont.ToString("MMMM");
     list.Value = NextMont.Month.ToString();
     ((DropDownList)(FVInvestigations.FindControl("ddlIssuanceMonth"))).Items.Add(list);
 }

Open in new window

Avatar of ankitkumar29
ankitkumar29
Flag of India image

Unless you add list items, makes no sense to set selectedvalue

<asp:DropDownList ID="ddlIssuanceMonth" runat="server"  Enabled="false"
                                            SelectedValue='<%#DataBinder.Eval(Container.DataItem,"IssuanceMonth")%>'>
      

 <asp:ListItem Text="1" Value="1"></asp:ListItem>
    <asp:ListItem Text="2" Value="2"></asp:ListItem>
    <asp:ListItem Text="3" Value="3"></asp:ListItem>
                                     </asp:DropDownList>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of guru_sami
guru_sami
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial