News:

SQL Table To C# Entity Model ConverterEntity Model (Class Properties) to SQL Table ConverterIf you encounter any trouble visiting our site, please contact us.

Advertisement

Looking for job. Try JobLoader- First ever job search engine in Bangladesh. All open bd jobs now a single mouse click away.

;

<asp:PlaceHolder ID="dynamicControls" runat="server">
<asp:DropDownList ID="MyDropDown" runat="server">
<asp:ListItem Text="abc" value="abc" />
<asp:ListItem Text="def" value="def" />
</asp:DropDownList>
</asp:PlaceHolder>
You need to dynamically add values to the end of the drop-down list.
What should you do?

  1. Add the following OnPreRender event handler to the asp:DropDownList

    protected void MyDropDown_PreRender(object sender, EventArgs e) {
    DropDownList ddl = sender as DropDownList;
    Label lbl = new Label();
    lbl.Text = "Option";
    lbl.ID = "Option";
    ddl.Controls.Add(lbl);
    }
    
  2. Add the following OnPreRender event handler to the asp:DropDownList

    protected void MyDropDown_PreRender(object sender, EventArgs e)
    {
    DropDownList ddl = sender as DropDownList;
    ddl.Items.Add("Option");
    }
    
  3. Add the following event handler to the page code-behind.

    protected void Page_LoadComplete(object sender, EventArgs e) {
    DropDownList ddl = Page.FindControl("MyDropDown") as DropDownList; Label lbl = new Label();
    lbl.Text = "Option";
    lbl.ID = "Option";
    ddl.Controls.Add(lbl);
    }
    
  4. Add the following event handler to the page code-behind.

    protected void Page_LoadComplete(object sender, EventArgs e) {
    DropDownList ddl = Page.FindControl("MyDropDown") as DropDownList; ddl.Items.Add("Option");
    }
    
Answer: Answer is b
comments powered by Disqus
Advertisement

BCS Preparation now even more easy. ReadBD is the place where you can find all kind of resources to be successful in BCS,Bank,Islami Bank exam and interview.

Looking for job. Try JobLoader- First ever job search engine in Bangladesh. All open bd jobs now a single mouse click away.

;