Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Bind DropDpwnlist

1 view
Skip to first unread message

marios...@gmail.com

unread,
Aug 8, 2014, 2:20:22 PM8/8/14
to
Salve a tutti

io ho un form con una listview dalla quale tramite un pulsante edit dovrei entrare in modalità update. DrpTipoAffiliato è una dropDownlist

Ma quando vado a cliccare sul pulsante ottengo l'errore sotto riportato:

SelectedValue in 'DrpTipoAffiliato' non valido, poiché non è incluso nell'elenco di elementi.

Posto un po di codice, spero non sia troppo e spero gli diate uno sguardo.
Ci sto sbattendo la testa da un po' di giorni ho provato tutto quello che ho trovato sul web.

Grazie in anticipo a tutti.

<asp:DropDownList ID="DrpIdaffiliati" runat="server"
style="position:absolute;
top: 250px;
left: 67px;
width: 40px;
height: 22px; right: 964px;"
AutoPostBack="True"
DataSourceID="AffiliatiSource"
DataTextField="IdAffiliato"
DataValueField="IdAffiliato"
OnSelectedIndexChanged="DrpIdaffililiati_SelectedIndexChanged"
AppendDataBoundItems="true">
<asp:ListItem Text="" Value=""/>

</asp:DropDownList>

<asp:DropDownList ID="DrpDescrizioneAff" runat="server"
style="position:absolute;
top: 250px;
left: 115px;
width: 242px;
height: 22px; right: 714px;"
AutoPostBack="True"
DataSourceID="AffiliatiSource"
DataTextField="Descrizione"
DataValueField="IdAffiliato"
OnSelectedIndexChanged="DrpDescrizioneAff_SelectedIndexChanged"
AppendDataBoundItems="true">
<asp:ListItem Text="" Value=""/>

</asp:DropDownList>

<asp:DropDownList ID="DrpTipoAffiliato" runat="server"
Style="position: absolute;
top: 250px;
left: 362px;
width: 99px;
width: 130px;
height: 22px;"
AutoPostBack="True"
DataSourceID="AffiliatiSource"
DataValueField="IdAffiliato"
DataTextField="Sigla"
OnSelectedIndexChanged="DrpDescrizioneAff_SelectedIndexChanged"
AppendDataBoundItems="True" >
<asp:ListItem Text="" Value=""/>
</asp:DropDownList>




<asp:Label ID="LblRagSoc"
runat="server"
text="Company"
style="position:absolute;
top: 230px;
left: 503px; right: 606px;"
ForeColor="White"
Font-Size="18px"/>

<asp:TextBox ID="TxtRagioneSociale"
runat="server"
style="position:absolute;
top: 250px;
left: 503px;
width: 367px;
height: 22px;" />

<asp:Label ID="LblDataAff"
runat="server"
Text="Date Affiliation"
Style="position:absolute;
top: 230px;
left: 882px"
ForeColor="White"
Font-Size="18px"/>

<asp:TextBox ID="TxtDataAff"
runat="server"
style="position:absolute;
top: 250px;
left: 883px;
width: 189px; height: 22px;"/>

<asp:ImageButton Id="ImgDataAff"
runat="server"
Imageurl="~/calendar-icon.png"
Height="22px"
style="position:absolute;
top: 250px;
left: 1085px" />

<cc1:CalendarExtender ID="CDataAff"
PopUpButtonID="ImgDataAff"
runat="server"
TargetControlId="TxtDataAff"
Format="dd/MM/yyyy">
</cc1:CalendarExtender>

<asp:Label ID="LblResp"
runat="server"
Text="Responsible"
Style="position: absolute;
top: 280px;
Left: 67px"
ForeColor="White"
Font-Size="18px"/>

<asp:TextBox ID="TxtResp"
runat="server"
style="position: absolute;
top: 300px;
left: 67px;
width: 189px;
height: 22px"/>

<asp:Label ID="LblIndirizzo"
runat="server"
Text="Street Address"
Style="position:absolute;
top: 280px;
left: 267px"
ForeColor="White"
Font-Size="18px"/>


<asp:TextBox ID="Txtindirizzo"
runat="server"
style="position:absolute;
top: 300px;
left: 267px;
width: 189px;
height: 22px; right: 455px;"/>

<asp:Label ID="LblLoc"
runat="server"
Text="Location"
Style="position:absolute;
top: 280px;
left: 466px"
ForeColor="White"
Font-Size="18px"/>

<asp:TextBox ID="TxtLocalità"
runat="server"
style="position: absolute;
top: 300px;
left: 466px;
width: 189px;
height: 22px"/>

<asp:Label ID="LblCap"
runat="server"
Text="Zip Code"
Style="position:absolute;
top: 280px;
left: 665px"
ForeColor="White"
Font-Size="18px"/>

<asp:TextBox ID="TxtCap"
runat="server"
Style="position: absolute;
top: 300px;
left: 665px;
width: 189px;
height: 22px"/>

<asp:Label ID="LblProvincia"
runat="server"
Text="Country"
Style="position:absolute;
top: 280px;
left: 864px"
ForeColor="White"
Font-Size="18px"/>

<asp:TextBox ID="TxtProvincia"
runat="server"
style="position: absolute;
top: 300px;
left: 864px;
width: 189px;
height:22px"/>

<asp:Label ID="LblStato"
runat="server"
Text="State"
Style="position:absolute;
top: 330px;
left: 67px"
ForeColor="White"
Font-Size="18px"/>

<asp:TextBox ID="TxtStato"
runat="server"
style="position: absolute;
top: 350px;
left: 67px;
width: 189px;
height: 22px "/>

<asp:Label ID="LblEmail"
runat="server"
Text="Email"
Style="position:absolute;
top: 330px;
left: 267px"
ForeColor="White"
Font-Size="18px"/>

<asp:TextBox ID="TxtEmail"
runat="server"
style="position: absolute;
top: 350px;
left: 268px;
width: 189px;
height: 22px; right: 454px;"/>

<asp:Label ID="LblTel"
runat="server"
Text="Phone"
Style="position:absolute;
top: 330px;
left: 466px"
ForeColor="White"
Font-Size="18px"/>

<asp:TextBox ID="TxtTel"
runat="server"
style="position:absolute;
top:350px;
left: 466px;
width: 189px;
height: 22px"/>

<asp:Label ID="LblFax"
runat="server"
Text="Fax"
Style="position:absolute;
top: 330px;
left: 665px"
ForeColor="White"
Font-Size="18px"/>

<asp:TextBox ID="TxtFax"
runat="server"
Style="position:absolute;
top: 350px;
left: 665px;
width: 189px;
height: 22px; right: 382px;"/>

<asp:Label ID="LblCell"
runat="server"
Text="Cell Phone"
Style="position:absolute;
top: 330px;
left: 864px"
ForeColor="White"
Font-Size="18px"/>

<asp:TextBox ID="TxtCel"
runat="server"
Style="position: absolute;
top: 350px;
left: 864px;
width: 189px;
height: 22px "/>

<asp:Label ID="LblPIva"
runat="server"
Text="P.Iva"
Style="position:absolute;
top: 380px;
left: 466px"
ForeColor="White"
Font-Size="18px"/>

<asp:TextBox ID="TxtPIva"
runat="server"
Style="position: absolute;
top: 400px;
left: 466px;
width: 189px;
height: 22px"/>


<asp:Button ID="BtnSalva"
runat="server"
Text="Save"
Style="position:absolute;
width: 103px;
height: 24px;
top: 500px;
left: 466px;
outline:none;
-moz-border-radius: 8px;
-web-kit-radius: 8px;
-border-radius: 8px"
BackColor="Black"
BorderColor="White"
BorderStyle="Solid"
Font-Bold="False"
Font-Names="Times New Roman"
Font-Overline="False"
Font-Size="18px"
ForeColor="Red" />

<asp:SqlDataSource
ID="AffiliatiSource"
runat="server"

ConnectionString="<%$ ConnectionStrings:EsaWebConnectionString %>"
SelectCommand="SELECT [IdAffiliato], [Sigla], [Descrizione] FROM [T_Affiliati]"></asp:SqlDataSource>
</table>
<br />
<br />
<asp:ListView ID="ListView1"
runat="server"
DataKeyNames="IdEsapoint"
DataSourceID="EPSource"
style="-moz-border-radius: 8px" >
<LayoutTemplate>
<div style="overflow: auto; margin-left: 10px; width: 1157px; height: 278px">
<table id="Table1" runat="server">
<tr id="Tr1" runat="server">
<td id="Td1" runat ="server">
<table id="itemplaceholderContainer" runat="server" border="1"
style="background-color: #FFFFFF; border-collapse: collapse;
border-color: #999999; border-bottom-style: none; border-width: 1px;
font-family: 'Times New Roman', Verdana, Helvetica, sans-serif; overflow:auto">
<tr runat="server" id="Intestazione1" style="background-color: black; color: white">
<th id="Th0" runat="server">Edit</th>
<th id="Th1" runat="server">IDEsaPoint</th>
<th id="Th2" runat="server">IdAffiliato</th>
<th id="Th3" runat="server">TipoAffiliato</th>
<th id="Th4" runat="server">RagioneSociale</th>
<th id="Th5" runat="server">DataAffiloiazione</th>
<th id="Th6" runat="server">Responsabile</th>
<th id="Th7" runat="server">Indirizzo</th>
<th id="Th8" runat="server">Località</th>
<th id="Th9" runat="server">Cap</th>
<th id="Th10" runat="server">Provincia</th>
<th id="Th11" runat="server">Stato</th>
<th id="Th12" runat="server">Email</th>
<th id="Th13" runat="server">Telefono</th>
<th id="Th14" runat="server">Fax</th>
<th id="Th15" runat="server">Cellulare</th>
<th id="Th16" runat="server">PIva</th>
</tr>
<tr id="itemPlaceholder" runat="server"></tr>
</table>
</td>
</tr>
</table>
</div>
</LayoutTemplate>
<ItemTemplate>
<tr style="background-color: #DCDCDC; color: #000000">
<td>
<asp:Button ID="EditButton"
runat="server"
Text="Edit"
CommandName="Aggiorna"
CommandArgument='<%# Eval("IDEsaPoint")%>'
OnCommand="EditButton_Command" />
</td>
<td>
<asp:Label ID="LblIDEsaPoint" runat="server"
Text='<%# Eval("IDEsaPoint")%>'/>
</td>

<td>
<asp:Label ID="LblIdAffiliato" runat="server"
Text='<%# Eval("IdAffiliato")%>'/>
</td>

<td>
<asp:Label ID="LblTipoAffiliato" runat="server"
Text='<%# Eval("TipoAffiliato")%>'/>
</td>
<td>
<asp:Label ID="LblRagioneSociale" runat="server"
Text='<%# Eval("RagioneSociale")%>'/>
</td>
<td>
<asp:Label ID="LblDataAffiliazione" runat="server"
Text='<%# Eval("DataAffiliazione")%>'/>
</td>
<td>
<asp:label ID="LblResponsabile" runat="server"
Text='<%# Eval("Responsabile")%>'/>
</td>
<td>
<asp:Label ID="LblIndirizzo" runat="server"
Text='<%# Eval("Indirizzo")%>' />
</td>
<td>
<asp:Label ID="LblLocalità" runat="server"
Text='<%# Eval("Località")%>' />
</td>
<td>
<asp:Label ID="LblCap" runat="server"
Text='<%# Eval("Cap")%>'/>
</td>
<td>
<asp:Label ID="LblProvincia" runat="server"
Text='<%# Eval("Provincia")%>'/>
</td>
<td>
<asp:Label ID="LblStato" runat="server"
Text='<%# Eval("Stato")%>'/>
</td>
<td>
<asp:Label ID="LblEmail" runat="server"
Text='<%#Eval("Email")%>'/>
</td>
<td>
<asp:Label ID="LblTelefono" runat="server"
Text='<%# Eval("Telefono")%>'/>
</td>
<td>
<asp:Label ID="LblFax" runat="server"
Text='<%# Eval("FAx")%>'/>
</td>
<td>
<asp:Label ID="LblCellulare" runat="server"
Text='<%# Eval("Cellulare")%>'/>
</td>
<td>
<asp:Label ID="LblPIva" runat="server"
Text='<%# Eval("PIva") %>'/>
</td>
</tr>
</ItemTemplate>
<EditItemTemplate>
<tr id="Tr2" runat="server" style="background-color: #008A8C; color:#FFFFFF">
<td>
<asp:Button ID="Btnedit" runat="server"
commandName="Update"
Text="Update"/>
</td>

<td>
<asp:Label ID="LblIDEsaPoint" runat="server"
Text='<%# Eval("IDEsaPoint")%>'/>
</td>

<td>
<asp:DropDownList ID="DrpIdAffiliati" runat="server"
SelectedValue='<%# Bind("IdAffiliato")%>'>
</asp:DropDownList>

</td>
<td>
<asp:DropDownList ID="DrpTipoAffiliato" runat="server"
SelectedValue='<%# Bind("TipoAffiliato")%>'>
</asp:DropDownList>

</td>
<td>
<asp:TextBox ID="TxtRagioneSociale" runat="server"
Text='<%# Bind("RagioneSociale")%>'/>
</td>
<td>
<asp:TextBox ID="TxtDataAff" runat="server"
Text='<%# Bind("DataAffiliazione")%>'/>
</td>
<td>
<asp:TextBox ID="TxtRes" runat="server"
Text='<%# Bind("Responsabile")%>'/>
</td>
<td>
<asp:TextBox ID="TxtIndirizzo" runat="server"
Text='<%# Bind("Indirizzo")%>' />
</td>
<td>
<asp:TextBox ID="TxtLocalità" runat="server"
Text='<%# Bind("Località")%>' />
</td>
<td>
<asp:TextBox ID="TxtCap" runat="server"
Text='<%# Bind("Cap")%>'/>
</td>
<td>
<asp:TextBox ID="TxtProvincia" runat="server"
Text='<%# Bind("Provincia")%>'/>
</td>
<td>
<asp:TextBox ID="TxtStato" runat="server"
Text='<%# Bind("Stato")%>'/>
</td>
<td>
<asp:TextBox ID="TxtEmail" runat="server"
Text='<%#Bind("Email")%>'/>
</td>
<td>
<asp:TextBox ID="TxtTel" runat="server"
Text='<%# Bind("Telefono")%>'/>
</td>
<td>
<asp:TextBox ID="TxtFax" runat="server"
Text='<%# Bind("Fax")%>'/>
</td>
<td>
<asp:TextBox ID="TxtCel" runat="server"
Text='<%# Bind("Cellulare")%>'/>
</td>
<td>
<asp:TextBox ID="TxtPIva" runat="server"
Text='<%# Bind("PIva")%>'/>
</td>
</tr>
</EditItemTemplate>
</asp:ListView>

<asp:SqlDataSource ID="EPSource"
runat="server"
ConnectionString="<%$ ConnectionStrings:EsaWebConnectionString %>"

Deletecommand="DELETE FROM [T_EsaPoint] Where [IDEsaPoint] = [@IDEsaPoint]"
InsertCommand="Insert Into (T_EsaPoint [IdAffiliato], [TipoAffiliato], [RagioneSociale],
[DataAffiliazione], [Responsabile], [Indirizzo],
[Località], [Cap], [Provincia], [Stato], [Email],
[Telefono], [Fax], [Cellulare], [PIva] Values
@IdAffiliato, @TipoAffiliato, @RagioneSociale, @DataAffiliazione, @Responsabile,
@Indirizzo, @Località, @Cap, @Provincia, @Stato, @Email, @Tlelefono, @Fax, @Cellulare,
@PIva"

SelectCommand="SELECT * FROM [T_EsaPoint]"
UpdateCommand ="Update [IdEsaPoint] SET [IdAffiliato] = @IdAffiliato,
[TipoAffiliato] = @TipoAffiliato, [RagioneSociale] = @RagioneSociale,
[DataAffiliazione] = @DataAffiliazione, [Responsabile] = @Responsabile,
[Indirizzo] = @Indirizzo, [Località] = @Località, [Cap] = @Cap,
[Provincia] = @Provincia, [Stato] = @Stato, [Email] = @Email,
[Telefono] = @Telefono, [Fax] = @Fax, [Cellulare] = @Cellulare,
[PIva] = @PIva">


<DeleteParameters>
<asp:Parameter Type="Int32" Name="IDEsaPoint" />
</DeleteParameters>
<InsertParameters>
<asp:Parameter Type="Int32" Name="IdAffiliato" />
<asp:Parameter Type="String" Name="TipoAffiliato" />
<asp:Parameter Type="String" Name="RagioneSociale" />
<asp:Parameter Type="DateTime" Name="DataAffiliazione" />
<asp:Parameter Type="String" Name="Responsabile" />
<asp:Parameter Type="String" Name="Indirizzo" />
<asp:Parameter Type="String" Name="Località" />
<asp:Parameter Type="String" Name="Cap" />
<asp:Parameter Type="String" Name="Provincia" />
<asp:Parameter Type="String" Name="Stato" />
<asp:Parameter Type="String" Name="Email" />
<asp:Parameter Type="String" Name="Telefono" />
<asp:Parameter Type="String" Name="Fax" />
<asp:Parameter Type="String" Name="Cellulare" />
<asp:Parameter Type="String" Name="PIva" />
</InsertParameters>
<UpdateParameters>
<asp:Parameter Type="Int32" Name="IDEsaPoint" />
<asp:Parameter Type="Int32" Name="IdAffiliato" />
<asp:Parameter Type="String" Name="TipoAffiliato" />
<asp:Parameter Type="String" Name="RagioneSociale" />
<asp:Parameter Type="DateTime" Name="DataAffiliazione" />
<asp:Parameter Type="String" Name="Responsabile" />
<asp:Parameter Type="String" Name="Indirizzo" />
<asp:Parameter Type="String" Name="Località" />
<asp:Parameter Type="String" Name="Cap" />
<asp:Parameter Type="String" Name="Provincia" />
<asp:Parameter Type="String" Name="Stato" />
<asp:Parameter Type="String" Name="Email" />
<asp:Parameter Type="String" Name="Telefono" />
<asp:Parameter Type="String" Name="Fax" />
<asp:Parameter Type="String" Name="Cellulare" />
<asp:Parameter Type="String" Name="PIva" />

</UpdateParameters>
</asp:SqlDataSource>
</div>
</form>
</body>
</html>
0 new messages