Discussion:
problem to insert value in dropdownlist on formView control
Lior Levy
2008-09-15 17:28:22 UTC
Permalink
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
Richard
2008-09-15 17:56:23 UTC
Permalink
Insert it at design time. Then enable a property something like
MergeDataboundAndStaticEntries. I am sure it's name is nothing like that,
but that's what it does!

Cheers,

- Richard

***@dynamisys.co.uk
www.dynamisys.co.uk
Land line +44 1793 731225
Mobile +44 7732 971786

-----Original Message-----
From: Discussion of building .NET applications targeted for the Web
[mailto:DOTNET-***@DISCUSS.DEVELOP.COM] On Behalf Of Lior Levy
Sent: 15 September 2008 18:28
To: DOTNET-***@DISCUSS.DEVELOP.COM
Subject: [DOTNET-WEB] problem to insert value in dropdownlist on formView
control



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 DevelopMentorR http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com
No virus found in this incoming message.
Checked by AVG - http://www.avg.com
Version: 8.0.169 / Virus Database: 270.6.21/1671 - Release Date: 9/14/2008
7:16 AM

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

View archives and manage your subscription(s) at http://discuss.develop.com
lior levi
2008-09-15 18:15:08 UTC
Permalink
Hi Richard,
I tried to at first but didn't found any property like
MergeDataboundAndStaticEntries.



-----Original Message-----
From: Discussion of building .NET applications targeted for the Web
[mailto:DOTNET-***@DISCUSS.DEVELOP.COM] On Behalf Of Richard
Sent: Monday, September 15, 2008 8:56 PM
To: DOTNET-***@DISCUSS.DEVELOP.COM
Subject: Re: [DOTNET-WEB] problem to insert value in dropdownlist on
formView control

Insert it at design time. Then enable a property something like
MergeDataboundAndStaticEntries. I am sure it's name is nothing like that,
but that's what it does!

Cheers,

- Richard

***@dynamisys.co.uk
www.dynamisys.co.uk
Land line +44 1793 731225
Mobile +44 7732 971786

-----Original Message-----
From: Discussion of building .NET applications targeted for the Web
[mailto:DOTNET-***@DISCUSS.DEVELOP.COM] On Behalf Of Lior Levy
Sent: 15 September 2008 18:28
To: DOTNET-***@DISCUSS.DEVELOP.COM
Subject: [DOTNET-WEB] problem to insert value in dropdownlist on formView
control



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 DevelopMentorR http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com
No virus found in this incoming message.
Checked by AVG - http://www.avg.com
Version: 8.0.169 / Virus Database: 270.6.21/1671 - Release Date: 9/14/2008
7:16 AM

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

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

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

View archives and manage your subscription(s) at http://discuss.develop.com
Chris Gallucci
2008-09-15 18:19:45 UTC
Permalink
Whenever I've needed to do this, I've always addressed it at the sql
source...

SELECT id, description FROM picklist
UNION
SELECT -1 AS id, '(Add New) AS description

HTH,

Chris Gallucci


-----Original Message-----
From: Discussion of building .NET applications targeted for the Web
[mailto:DOTNET-***@DISCUSS.DEVELOP.COM] On Behalf Of lior levi
Sent: Monday, September 15, 2008 1:15 PM
To: DOTNET-***@DISCUSS.DEVELOP.COM
Subject: Re: [DOTNET-WEB] problem to insert value in dropdownlist on
formView control

Hi Richard,
I tried to at first but didn't found any property like
MergeDataboundAndStaticEntries.



-----Original Message-----
From: Discussion of building .NET applications targeted for the Web
[mailto:DOTNET-***@DISCUSS.DEVELOP.COM] On Behalf Of Richard
Sent: Monday, September 15, 2008 8:56 PM
To: DOTNET-***@DISCUSS.DEVELOP.COM
Subject: Re: [DOTNET-WEB] problem to insert value in dropdownlist on
formView control

Insert it at design time. Then enable a property something like
MergeDataboundAndStaticEntries. I am sure it's name is nothing like that,
but that's what it does!

Cheers,

- Richard

***@dynamisys.co.uk
www.dynamisys.co.uk
Land line +44 1793 731225
Mobile +44 7732 971786

-----Original Message-----
From: Discussion of building .NET applications targeted for the Web
[mailto:DOTNET-***@DISCUSS.DEVELOP.COM] On Behalf Of Lior Levy
Sent: 15 September 2008 18:28
To: DOTNET-***@DISCUSS.DEVELOP.COM
Subject: [DOTNET-WEB] problem to insert value in dropdownlist on formView
control



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 DevelopMentorR http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com
No virus found in this incoming message.
Checked by AVG - http://www.avg.com
Version: 8.0.169 / Virus Database: 270.6.21/1671 - Release Date: 9/14/2008
7:16 AM

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

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

===================================
This list is hosted by DevelopMentorR http://www.develop.com

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

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

View archives and manage your subscription(s) at http://discuss.develop.com
lior levi
2008-09-15 18:51:06 UTC
Permalink
Nice idea
It will do the job.

thank you Chris.

-----Original Message-----
From: Discussion of building .NET applications targeted for the Web
[mailto:DOTNET-***@DISCUSS.DEVELOP.COM] On Behalf Of Chris Gallucci
Sent: Monday, September 15, 2008 9:20 PM
To: DOTNET-***@DISCUSS.DEVELOP.COM
Subject: Re: [DOTNET-WEB] problem to insert value in dropdownlist on
formView control

Whenever I've needed to do this, I've always addressed it at the sql
source...

SELECT id, description FROM picklist
UNION
SELECT -1 AS id, '(Add New) AS description

HTH,

Chris Gallucci


-----Original Message-----
From: Discussion of building .NET applications targeted for the Web
[mailto:DOTNET-***@DISCUSS.DEVELOP.COM] On Behalf Of lior levi
Sent: Monday, September 15, 2008 1:15 PM
To: DOTNET-***@DISCUSS.DEVELOP.COM
Subject: Re: [DOTNET-WEB] problem to insert value in dropdownlist on
formView control

Hi Richard,
I tried to at first but didn't found any property like
MergeDataboundAndStaticEntries.



-----Original Message-----
From: Discussion of building .NET applications targeted for the Web
[mailto:DOTNET-***@DISCUSS.DEVELOP.COM] On Behalf Of Richard
Sent: Monday, September 15, 2008 8:56 PM
To: DOTNET-***@DISCUSS.DEVELOP.COM
Subject: Re: [DOTNET-WEB] problem to insert value in dropdownlist on
formView control

Insert it at design time. Then enable a property something like
MergeDataboundAndStaticEntries. I am sure it's name is nothing like that,
but that's what it does!

Cheers,

- Richard

***@dynamisys.co.uk
www.dynamisys.co.uk
Land line +44 1793 731225
Mobile +44 7732 971786

-----Original Message-----
From: Discussion of building .NET applications targeted for the Web
[mailto:DOTNET-***@DISCUSS.DEVELOP.COM] On Behalf Of Lior Levy
Sent: 15 September 2008 18:28
To: DOTNET-***@DISCUSS.DEVELOP.COM
Subject: [DOTNET-WEB] problem to insert value in dropdownlist on formView
control



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 DevelopMentorR http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com
No virus found in this incoming message.
Checked by AVG - http://www.avg.com
Version: 8.0.169 / Virus Database: 270.6.21/1671 - Release Date: 9/14/2008
7:16 AM

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

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

===================================
This list is hosted by DevelopMentorR http://www.develop.com

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

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

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

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

View archives and manage your subscription(s) at http://discuss.develop.com
Richard
2008-09-15 21:48:35 UTC
Permalink
Ok - So it's called AppendDataBoundItems.

Cheers,

- Richard

***@dynamisys.co.uk
www.dynamisys.co.uk
Land line +44 1793 731225
Mobile +44 7732 971786
-----Original Message-----
From: Discussion of building .NET applications targeted for the Web
[mailto:DOTNET-***@DISCUSS.DEVELOP.COM] On Behalf Of lior levi
Sent: 15 September 2008 19:15
To: DOTNET-***@DISCUSS.DEVELOP.COM
Subject: Re: [DOTNET-WEB] problem to insert value in dropdownlist on
formView control

Hi Richard,
I tried to at first but didn't found any property like
MergeDataboundAndStaticEntries.



-----Original Message-----
From: Discussion of building .NET applications targeted for the Web
[mailto:DOTNET-***@DISCUSS.DEVELOP.COM] On Behalf Of Richard
Sent: Monday, September 15, 2008 8:56 PM
To: DOTNET-***@DISCUSS.DEVELOP.COM
Subject: Re: [DOTNET-WEB] problem to insert value in dropdownlist on
formView control

Insert it at design time. Then enable a property something like
MergeDataboundAndStaticEntries. I am sure it's name is nothing like that,
but that's what it does!

Cheers,

- Richard

***@dynamisys.co.uk
www.dynamisys.co.uk
Land line +44 1793 731225
Mobile +44 7732 971786

-----Original Message-----
From: Discussion of building .NET applications targeted for the Web
[mailto:DOTNET-***@DISCUSS.DEVELOP.COM] On Behalf Of Lior Levy
Sent: 15 September 2008 18:28
To: DOTNET-***@DISCUSS.DEVELOP.COM
Subject: [DOTNET-WEB] problem to insert value in dropdownlist on formView
control



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 DevelopMentorR http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com
No virus found in this incoming message.
Checked by AVG - http://www.avg.com
Version: 8.0.169 / Virus Database: 270.6.21/1671 - Release Date: 9/14/2008
7:16 AM

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

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

===================================
This list is hosted by DevelopMentorR http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com
No virus found in this incoming message.
Checked by AVG - http://www.avg.com
Version: 8.0.169 / Virus Database: 270.6.21/1673 - Release Date: 9/15/2008
6:49 PM

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

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