opensubscriber
   Find in this group all groups
 
Unknown more information…

d : dotnet-web@discuss.develop.com 16 September 2008 • 1:28AM -0400

[DOTNET-WEB] problem to insert value in dropdownlist on formView control
by Lior Levy

REPLY TO AUTHOR
 
REPLY TO GROUP





Hello,

I'm using the SqlDataSource to insert value in dropdownlist, but i want to add a -- Add New -- at the end of the
list, but can't find a way to make it.



It works very well if I delete the SqlDataSource of the DropDownlist...

maybe the inserted item is overwrited by the SqlDataSource !!?



protected void FormView1_ItemCreated(object sender, EventArgs e)

    {

        if (FormView1.CurrentMode == FormViewMode.Insert)

        {

            DropDownList dropDownList1;

            dropDownList1 = (DropDownList)FormView1.FindControl("DDL_ca");

            if (dropDownList1 != null)

            {

                dropDownList1.SelectedIndexChanged += new EventHandler(DDL_ca_SelectedIndexChanged);

                SqlDataSourceActions.ConnectionString = "ConnectionString";



                dropDownList1.Items.Add(new ListItem("Add New1", "999"));

                dropDownList1.DataSourceID = "SqlDataSourceActions";

                dropDownList1.DataValueField = "CA_code";

                dropDownList1.DataTextField = "CA_desc";

                dropDownList1.DataBind();

                dropDownList1.Items.Add(new ListItem("Add New2", "999"));

            }

        }

    }



Any Ideas?








===================================
This list is hosted by DevelopMentorĀ®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Bookmark with:

Delicious   Digg   reddit   Facebook   StumbleUpon

Related Messages

opensubscriber is not affiliated with the authors of this message nor responsible for its content.