Geeks With Blogs
AzamSharp Some day I will know everything. I hope that day never comes.

FormView control is a template control and hence it allows other controls to be embedded inside it. You can also place a DropDownList control inside the FormView control. The code below populates the DropDownList control which is placed inside the FormView control.

private void BindData()
        SqlConnection myConnection = 
new SqlConnection(ConnectionString);
        SqlDataAdapter ad = 
new SqlDataAdapter("SELECT * FROM Users", myConnection);
        DataSet ds = 
new DataSet();
        fv1.DataSource = ds;

        FormViewRow row = fv1.Row; 

// Populating the DropDownList Control inside the FormView control 
DropDownList ddlList  = (DropDownList) row.FindControl("ddlNames");
        ddlList.DataSource = GetNames();
        ddlList.DataTextField = "FirstName";
        ddlList.DataValueField = "UserID";




powered by IMHO 1.3

Posted on Monday, May 22, 2006 10:18 PM | Back to top

Comments on this post: Populating the DropDownList inside the FormView Control

# re: Populating the DropDownList inside the FormView Control
Requesting Gravatar...
how do i populate the same dropdownlist using the markup for the dropdownlist in .aspx page ?
when i try to assing another datasource to that control it generates an error
Left by serkan ┼čendur on Nov 26, 2007 10:24 PM

Your comment:
 (will show your gravatar)

Copyright © Mohammad Azam | Powered by: