When i apply dropdown list inside the listview they add only null value why?
Currently I have a dropdownlist with it's own sqldatasource that's populating the dropdownlist. The ddl is inside a listviews, which also has it's on sqldatasource, insert item template. However when we click insert the value passed to the dbase is a null.
When i apply single dropdown list using below code they work fine, But when i apply 2 dropdown list, second dropdown inherited with first dropdown they cannot work, They passing out null value.
First dropdown is "nationality" and second dropdown is a "province",
When i select nationality, than province will be automatically show from database, but when we aplly those dropdown inside listview than they add only null value.
But if i add only nationality dropdown, they successfully add data to the db
What I have tried:
<asp:ListView ID="ListView1" runat="server" DataSourceID="SqlDataSource3" DataKeyNames="AreaId" InsertItemPosition="LastItem">
<insertitemtemplate>
<asp:Button runat="server" CommandName="Insert" Text="Insert" ID="InsertButton" CssClass="btn-warning" Width="50px" Height="25px" />
<asp:Button runat="server" CommandName="Cancel" Text="Clear" ID="CancelButton" CssClass="btn-warning" Width="50px" Height="25px" />
<asp:UpdateProgress ID="UpdateProgress1" runat="server">
<progresstemplate>
<img alt="as" src="Images/loader1.gif" style="width: 30px; height: 30px" />
<asp:DropDownList ID="DropDownList1" runat="server" SelectedValue='<%# Bind("ProvinceId") %>' CssClass="form-control" AutoPostBack="true" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged" DataSourceID="SqlDataSource4" DataTextField="ProvinceName" DataValueField="ProvinceId">
<asp:SqlDataSource runat="server" ID="SqlDataSource4" ConnectionString='<%$ ConnectionStrings:CRMSConnectionString %>' SelectCommand="SELECT * FROM [Province]">
<asp:DropDownList ID="DropDownList4" runat="server" SelectedValue='<%# Bind("CityId") %>' CssClass="form-control" DataSourceID="SqlDataSource5" DataTextField="CityName" DataValueField="CityId">
<asp:SqlDataSource runat="server" ID="SqlDataSource5" ConnectionString='<%$ ConnectionStrings:CRMSConnectionString %>' SelectCommand="SELECT City.CityId, City.CityName FROM City INNER JOIN Province ON City.ProvinceId = Province.ProvinceId WHERE (City.ProvinceId = @ProvinceId)">
<SelectParameters>
<asp:ControlParameter ControlID="DropDownList1" PropertyName="SelectedValue" Name="ProvinceId">
</SelectParameters>
<asp:TextBox Text='<%# Bind("AreaName") %>' runat="server" ID="AreaNameTextBox" CssClass="form-control" />
<asp:SqlDataSource runat="server" ID="SqlDataSource3" ConnectionString='<%$ ConnectionStrings:CRMSConnectionString %>' DeleteCommand="DELETE FROM [Area] WHERE [AreaId] = @AreaId" InsertCommand="INSERT INTO [Area] ([AreaName], [CityId], [ProvienceId]) VALUES (@AreaName, @CityId, @ProvienceId)" SelectCommand="SELECT * FROM [Area]" UpdateCommand="UPDATE [Area] SET [AreaName] = @AreaName, [CityId] = @CityId, [ProvienceId] = @ProvienceId WHERE [AreaId] = @AreaId">
<deleteparameters>
<asp:Parameter Name="AreaId" Type="Int32">
<insertparameters>
<asp:Parameter Name="AreaName" Type="String">
<asp:Parameter Name="CityId" Type="Int32">
<asp:Parameter Name="ProvienceId" Type="Int32">
<updateparameters>
<asp:Parameter Name="AreaName" Type="String">
<asp:Parameter Name="CityId" Type="Int32">
<asp:Parameter Name="ProvienceId" Type="Int32">
<asp:Parameter Name="AreaId" Type="Int32">