hi all... i have create a registration form using Form View tool in asp.net..and i have a drop down list in form..
i use dropdown list in my cs page but i can't get the data into my drop down list in Form View Insert Template..(but no error display)
i use this code to get data to drop down list..
protected void Page_Load(object sender, Event Args e) { DropDownList ddlFreigh = (DropDownList)(FormView1.FindControl("ddlFreigh")); if (!IsPostBack) { // Create a database variable SqlConnection connection = new SqlConnection(); // Set the connection string of the database connection.ConnectionString = ConfigurationManager.ConnectionStrings[databaseConnectionStringName].ToString(); try { connection.Open(); #region Loading freigh to drop down list SqlCommand freighCommand = connection.CreateCommand(); freighCommand.CommandText = "SELECT Value FROM UDFList WHERE Name='FREIGH'"; freighCommand.CommandType = CommandType.Text; string freighString = freighCommand.ExecuteScalar().ToString(); string[] listOfFreigh = freighString.Split(); ddlFreigh.Items.Clear(); foreach (string freigh in listOfFreigh) { ddlFreigh.Items.Add(freigh); } freighCommand.Dispose(); #endregion } catch { } finally { try { connection.Close(); } catch { } } }