ecco quà:
<asp:SqlDataSource ID="ComuniSql" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionStringDataBase %>"
DeleteCommand="DELETE FROM [Comuni] WHERE [ID] = @ID" InsertCommand="INSERT INTO [Comuni] ([ID], [Nome], [IDProvincia]) VALUES (@ID, @Nome, @IDProvincia)"
SelectCommand="SELECT [ID], [Nome], [IDProvincia] FROM [Comuni]" UpdateCommand="UPDATE [Comuni] SET [Nome] = @Nome, [IDProvincia] = @IDProvincia WHERE [ID] = @ID">
<DeleteParameters>
<asp:Parameter Name="ID" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="Nome" Type="String" />
<asp:Parameter Name="IDProvincia" Type="Int32" />
<asp:Parameter Name="ID" Type="Int32" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="ID" Type="Int32" />
<asp:Parameter Name="Nome" Type="String" />
<asp:Parameter Name="IDProvincia" Type="Int32" />
</InsertParameters>
</asp:SqlDataSource>
<asp:FormView ID="FormView1" runat="server" AllowPaging="True" DataKeyNames="ID"
DataSourceID="ComuniSql">
<EditItemTemplate>
ID:
<asp:Label ID="IDLabel1" runat="server" Text='<%# Eval("ID") %>'></asp:Label><br />
Nome:
<asp:TextBox ID="NomeTextBox" runat="server" Text='<%# Bind("Nome") %>'></asp:TextBox><br />
<asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="ProvincineSQl"
DataTextField="Nome" DataValueField="ID" SelectedValue='<%# Bind("IDProvincia") %>'>
</asp:DropDownList><br />
<asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update"
Text="Update"></asp:LinkButton>
<asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
Text="Cancel"></asp:LinkButton>
<asp:SqlDataSource ID="ProvincineSQl" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionStringDataBase %>"
SelectCommand="SELECT [ID], [Nome] FROM [Provincie]"></asp:SqlDataSource>
</EditItemTemplate>
<InsertItemTemplate>
ID:
<asp:TextBox ID="IDTextBox" runat="server" Text='<%# Bind("ID") %>'>
</asp:TextBox><br />
Nome:
<asp:TextBox ID="NomeTextBox" runat="server" Text='<%# Bind("Nome") %>'>
</asp:TextBox><br />
<asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" CommandName="Insert"
Text="Insert">
</asp:LinkButton>
<asp:LinkButton ID="InsertCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
Text="Cancel">
</asp:LinkButton>
</InsertItemTemplate>
<ItemTemplate>
ID:
<asp:Label ID="IDLabel" runat="server" Text='<%# Eval("ID") %>'></asp:Label><br />
Nome:
<asp:Label ID="NomeLabel" runat="server" Text='<%# Bind("Nome") %>'></asp:Label><br />
<br />
<asp:LinkButton ID="EditButton" runat="server" CausesValidation="False" CommandName="Edit"
Text="Edit"></asp:LinkButton>
<asp:LinkButton ID="DeleteButton" runat="server" CausesValidation="False" CommandName="Delete"
Text="Delete"></asp:LinkButton>
<asp:LinkButton ID="NewButton" runat="server" CausesValidation="False" CommandName="New"
Text="New"></asp:LinkButton>
</ItemTemplate>
</asp:FormView>
SqlDataSource che alimenta la DropDownList è all'interno della Template ma non cambia niente anche se la metti all'esterno.
ciao marco