Hi landomarossi,
Please refer below sample.
HTML
<form id="form1" runat="server">
<asp:DropDownList ID="ddlFruits" runat="server">
<asp:ListItem Text="Please Select" Value="0" />
<asp:ListItem Text="Mango" Value="1" />
<asp:ListItem Text="Apple" Value="2" />
<asp:ListItem Text="Banana" Value="3" />
<asp:ListItem Text="Orange" Value="4" />
</asp:DropDownList>
<br />
<br />
<asp:Button ID="btnClone" Text="Clone" runat="server" />
<hr />
<div id="container">
</div>
<br />
<asp:Button ID="btnSubmit" Text="Save" runat="server" OnClick="Save" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
$(function () {
$("[id*=btnClone]").bind("click", function () {
var index = $("#container select").length + 1;
var ddl = $("[id$=ddlFruits]").clone();
ddl.attr("id", "ddlFruits_" + index);
ddl.attr("name", "ddlFruits_" + index);
//ddl.find("option[value = '" + $("[id$=ddlFruits] option:selected").val() + "']").attr("selected", "selected");
$('select').each(function () {
ddl.find('option[value="' + $(this).find('option:selected').val() + '"]').remove();
});
$("#container").append(ddl);
$("#container").append("<br /><br />");
return false;
});
});
</script>
Code
C#
protected void Save(object sender, EventArgs e)
{
List<string> value1 = new List<string>();
foreach (string item in Request.Form)
{
if (item.StartsWith("ddlFruits_"))
{
value1.Add(Request.Form[item]);
}
}
ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Selected Fruits:\\n" + string.Join(",", value1) + "');", true);
}
VB.Net
Protected Sub Save(ByVal sender As Object, ByVal e As EventArgs)
Dim value1 As List(Of String) = New List(Of String)()
For Each item As String In Request.Form
If item.StartsWith("ddlFruits_") Then
value1.Add(Request.Form(item))
End If
Next
ClientScript.RegisterStartupScript(Me.GetType(), "alert", "alert('Selected Fruits:\n" & String.Join(",", value1) & "');", True)
End Sub
Screenshot