Вставка Formview не работает, если autopostback=true . asp.net

#c# #asp.net #webforms

#c# #asp.net #веб-формы

Вопрос:

У меня есть страница с dropdownlist прикрепленным selectedIndexChanged событием. Итак, для каждого параметра в dropdownlist , есть usercontrol , который содержит форму, относящуюся к этому разделу. (каждый пользовательский элемент управления находится на панели, и selectedIndexChanged событие переключает видимость этой панели.

Однако для одной из форм я вставляю данные в SQL Server, поэтому использовал formview, только проблема заключалась в том, что он не вставлялся.

Потратив целую вечность на то, чтобы восстановить страницу, чтобы выяснить точку сбоя, выясняется AutoPostBack="true dropdownlist , что проблема возникает из-за «на». Даже когда я удаляю все остальные панели / usercontrols и делаю так, чтобы панель formview была видна всей команде (это означает, что dropdownlist она не изменена и, следовательно, возврат назад не происходит), она все равно просто терпит неудачу. Если я удалю это из выпадающего списка, данные не будут вставляться без проблем.

Кто-нибудь видел это раньше или может придумать логическую причину, по которой это может происходить?

Я опубликую код на dropdown всякий случай, если это поможет:

 <asp:Label ID="uxFormSwitchLabel" runat="server" Text="What would you like to do?" AssociatedControlID="uxFormSwitch" />
<asp:DropDownList ID="uxFormSwitch" runat="server" AutoPostBack="true" OnSelectedIndexChanged="uxFormSwitch_SelectedIndexChanged">
   <asp:ListItem Value="Please Select" Text="Please Select" Selected="True" />
   <asp:ListItem Value="Change my address" Text="Change my address" />
   <asp:ListItem Value="Change my bank details" Text="Change my bank details" />
   <asp:ListItem Value="Change my class of use" Text="Change my class of use" />
   <asp:ListItem Value="Change my personal details" Text="Change my personal details" />
   <asp:ListItem Value="Other" Text="Other" />
</asp:DropDownList>
  

ОБНОВЛЕНИЕ — в соответствии с запросом, вот код для вставки formview:

 <asp:FormView ID="uxDriverByID" runat="server" DataKeyNames="DriverID" DefaultMode="Insert" DataSourceID="dsDriverByID" ondatabound="uxDriverByID_DataBound" oniteminserting="uxDriverByID_ItemInserting">    
    <InsertItemTemplate>
        <asp:HiddenField ID="uxEntryType" runat="server" Value='<%# Bind("EntryType") %>' />

        <asp:Label ID="uxDateLabel" runat="server" AssociatedControlID="uxDate" Text="Date cover is to begin"></asp:Label>
        <asp:TextBox ID="uxDate" CssClass="datepicker" runat="server" Text='<%# Bind("StartDate") %>'></asp:TextBox>        
    <div class="clear"></div>        


        <asp:Label ID="uxEndDateLabel" runat="server" AssociatedControlID="uxEndDate" Text="Date cover is to begin"></asp:Label>
        <asp:TextBox ID="uxEndDate" CssClass="datepicker" runat="server" Text='<%# Bind("EndDate") %>'></asp:TextBox>

        <asp:Label ID="uxTitleLabel" runat="server" AssociatedControlID="uxTitle" Text="Title" ></asp:Label>
            <asp:DropDownList ID="uxTitle" runat="server" SelectedValue='<%# Bind("Title") %>'>
                <asp:ListItem Value="0" Text="Please Select" />
                <asp:ListItem Value="1" Text="Mr" />
                <asp:ListItem Value="2" Text="Mrs" />
                <asp:ListItem Value="3" Text="Miss" />
                <asp:ListItem Value="4" Text="Ms" />
                <asp:ListItem Value="5" Text="Doctor" />
            </asp:DropDownList>

    <asp:Label ID="uxFirstNameLabel" runat="server" AssociatedControlID="uxFirstName" Text="First Name"></asp:Label>
        <asp:TextBox ID="uxFirstName" runat="server" Text='<%# Bind("FirstName") %>'></asp:TextBox>

        <asp:Label ID="uxSurnameLabel" runat="server" AssociatedControlID="uxSurname" Text="Surname"></asp:Label>
        <asp:TextBox ID="uxSurname" runat="server" Text='<%# Bind("Surname") %>'></asp:TextBox>

        <asp:Label ID="uxDateOfBirthLabel" runat="server" AssociatedControlID="uxDay" Text="Date of birth"></asp:Label>
        <div class="input">
            <div class="dateofbirth">
                <asp:DropDownList ID="uxDay" runat="server">
                </asp:DropDownList>
                <asp:DropDownList ID="uxMonth" runat="server">
                </asp:DropDownList>
                <asp:DropDownList ID="uxYear" runat="server">
                </asp:DropDownList>
            </div>
        </div>

        <asp:Label ID="uxGenderLabel" runat="server" AssociatedControlID="uxGender" Text="Gender"></asp:Label>
        <div class="input">
        <asp:DropDownList ID="uxGender" runat="server" SelectedValue='<%# Bind("Gender") %>'>
            <asp:ListItem Value="0" Text="Please Select" />
            <asp:ListItem Value="1" Text="Male" />
            <asp:ListItem Value="2" Text="Female" />
        </asp:DropDownList>  

        <asp:Label ID="uxRelationshipLabel" runat="server" AssociatedControlID="uxRelationship"
            Text="Relationship to Proposer"></asp:Label>
            <asp:DropDownList ID="uxRelationship" runat="server" SelectedValue='<%# Bind("Relationship") %>'>
                <asp:ListItem Value="Please Select" Text="Please Select" />
                <asp:ListItem Value="Spouse" Text="Spouse" />
                <asp:ListItem Value="Common law partner" Text="Common law partner" />
                <asp:ListItem Value="Leasing company" Text="Leasing company" />
                <asp:ListItem Value="Parent" Text="Parent" />
                <asp:ListItem Value="Company" Text="Company" />
                <asp:ListItem Value="Other" Text="Other" />
            </asp:DropDownList>
        <div class="clear"></div>                

        <asp:Label ID="uxMaritalStatusLabel" runat="server" AssociatedControlID="uxMaritalStatus" Text="Marital Status"></asp:Label>
            <asp:DropDownList ID="uxMaritalStatus" runat="server" SelectedValue='<%# Bind("MaritalStatus") %>'>
                <asp:ListItem Value="Please Select" Text="Please Select" />
                <asp:ListItem Value="Married" Text="Married" />
                <asp:ListItem Value="Single" Text="Single" />
                <asp:ListItem Value="Divorced" Text="Divorced" />
                <asp:ListItem Value="Widowed" Text="Widowed" />
                <asp:ListItem Value="Separated" Text="Separated" />
                <asp:ListItem Value="Common Law" Text="Common Law" />
                <asp:ListItem Value="Civil Partner" Text="Civil Partner" />
            </asp:DropDownList>

        <asp:Label ID="uxEmploymentStatusLabel" AssociatedControlID="uxEmploymentStatus" runat="server" Text="Employment Status"/>
        <asp:DropDownList ID="uxEmploymentStatus" runat="server" SelectedValue='<%# Bind("EmploymentStatus") %>'>
            <asp:ListItem Value="0" Text="Please Select" />
            <asp:ListItem Value="1" Text="Employed" />
            <asp:ListItem Value="2" Text="Self Employed" />
            <asp:ListItem Value="3" Text="Retired" />
            <asp:ListItem Value="4" Text="Household Duties" />
            <asp:ListItem Value="5" Text="In Full or Part-time education" />
            <asp:ListItem Value="6" Text="Unemployed" />
            <asp:ListItem Value="7" Text="Company" />
            <asp:ListItem Value="8" Text="Independent Means" />
            <asp:ListItem Value="9" Text="Voluntary Work" />
        </asp:DropDownList> 

            <asp:Label ID="uxOccupationLabel" AssociatedControlID="uxOccupation" runat="server" Text="Occupation" />  
            <asp:TextBox ID="uxOccupation" runat="server" Text='<%# Bind("Occupation") %>'  />  

            <asp:Label ID="uxBusinessLabel" AssociatedControlID="uxBusiness" runat="server" Text="Employer's business" />  
            <asp:TextBox ID="uxBusiness" runat="server" Text='<%# Bind("Business") %>' />


            <asp:Label ID="uxSecondaryEmploymentLabel" runat="server" AssociatedControlID="uxSecondaryEmployment" Text="Does this driver have a second occupation?"></asp:Label>
             <asp:DropDownList ID="uxSecondaryEmployment" runat="server">
                <asp:ListItem Value="" Text="Please Select" />
                <asp:ListItem Value="No" Text="No" />
                <asp:ListItem Value="Yes" Text="Yes" />
            </asp:DropDownList>

            <asp:Label ID="uxSecondaryEmploymentStatusLabel" AssociatedControlID="uxSecondaryEmploymentStatus" runat="server" Text="Secondary Employment Status" />
            <asp:DropDownList ID="uxSecondaryEmploymentStatus" runat="server" SelectedValue='<%# Bind("SecondaryEmploymentStatus") %>'>
                <asp:ListItem Value="0" Text="Please Select" />
                <asp:ListItem Value="1" Text="Employed" />
                <asp:ListItem Value="2" Text="Self Employed" />
                <asp:ListItem Value="3" Text="Retired" />
                <asp:ListItem Value="4" Text="Household Duties" />
                <asp:ListItem Value="5" Text="In Full or Part-time education" />
                <asp:ListItem Value="6" Text="Unemployed" />
                <asp:ListItem Value="7" Text="Company" />
                <asp:ListItem Value="8" Text="Independent Means" />
                <asp:ListItem Value="9" Text="Voluntary Work" />
            </asp:DropDownList>

            <asp:Label ID="uxSecondaryOccupationLabel" AssociatedControlID="uxSecondaryOccupation" runat="server" Text="Secondary occupation" />  
            <asp:TextBox ID="uxSecondaryOccupation" runat="server" Text='<%# Bind("SecondaryOccupation") %>' />

            <asp:Label ID="uxSecondaryBusinessLabel" AssociatedControlID="uxSecondaryBusiness" runat="server" Text="Employer's business" />  
            <asp:TextBox ID="uxSecondaryBusiness" runat="server" Text='<%# Bind("SecondaryBusiness") %>' /> 

        <asp:Label ID="uxLicenceTypeLabel" runat="server" AssociatedControlID="uxLicenceType" Text="What type of licence does the driver hold?"></asp:Label>
            <asp:DropDownList ID="uxLicenceType" runat="server" SelectedValue='<%# Bind("LicenceType") %>'>
                <asp:ListItem Value="Please Select" Text="Please Select" />
                <asp:ListItem Value="Full(UK)" Text="Full(UK)" />
                <asp:ListItem Value="Provisional(UK)" Text="Provisional(UK)" />
                <asp:ListItem Value="Foreign" Text="Foreign" />
                <asp:ListItem Value="Restricted less than 3 years" Text="Restricted less than 3 years" />
                <asp:ListItem Value="Restricted 3 years or over" Text="Restricted 3 years or over" />
            </asp:DropDownList>

        <asp:Label ID="uxTimeHeldLabel" runat="server" AssociatedControlID="uxTimeHeld" Text="How many years has the driver held this licence?"></asp:Label>
        <asp:DropDownList ID="uxTimeHeld" runat="server" SelectedValue='<%# Bind("TimeHeld") %>'>
            <asp:ListItem Value="0" Text="0" />
            <asp:ListItem Value="1" Text="1" />
            <asp:ListItem Value="2" Text="2" />
            <asp:ListItem Value="3" Text="3" />
            <asp:ListItem Value="4" Text="4" />
            <asp:ListItem Value="5" Text="5" />
            <asp:ListItem Value="6" Text="6" />
            <asp:ListItem Value="7" Text="7" />
            <asp:ListItem Value="8" Text="8" />
            <asp:ListItem Value="9" Text="9 or over" />
        </asp:DropDownList>

        <asp:Label ID="uxClassSelectLabel" runat="server" AssociatedControlID="uxClassSelect" Text="What class of use do you want to change to?"></asp:Label>
        <asp:DropDownList ID="uxClassSelect" runat="server" SelectedValue='<%# Bind("ClassSelect") %>'>
            <asp:ListItem Value="Please Select" Text="Please Select" />
            <asp:ListItem Value="1" Text="SDP - Includes Commuting if Required" />
            <asp:ListItem Value="2" Text="Business Use Policy Holder In Person" />
            <asp:ListItem Value="3" Text="Business Use Spouse In Person" />
            <asp:ListItem Value="4" Text="usiness Use Policy Holder and Spouse" />
            <asp:ListItem Value="5" Text="Policy Holder Business - Authorised Drivers" />
            <asp:ListItem Value="6" Text="Commercial Travelling" />
        </asp:DropDownList>

        <asp:Label ID="uxConvictionsLabel" runat="server" AssociatedControlID="uxConvictions" Text="Has this driver had any motoring convictions in the last 5 years?"></asp:Label>
        <asp:DropDownList ID="uxConvictions" runat="server" SelectedValue='<%# Bind("Convictions") %>'>
            <asp:ListItem Value="" Text="Please Select" />
            <asp:ListItem Value="No" Text="No" />
            <asp:ListItem Value="Yes" Text="Yes" />
        </asp:DropDownList>


        <asp:Label ID="uxClaimsLabel" runat="server" AssociatedControlID="uxClaims" Text="Has this driver had any motoring claims in the last 5 years?"></asp:Label>
        <div class="input">
        <asp:DropDownList ID="uxClaims" runat="server" SelectedValue='<%# Bind("Claims") %>'>
            <asp:ListItem Value="" Text="Please Select" />
            <asp:ListItem Value="No" Text="No" />
            <asp:ListItem Value="Yes" Text="Yes" />
        </asp:DropDownList>


        <asp:Label ID="uxResidentLabel" runat="server" AssociatedControlID="uxResident" Text="How many years has this driver been a permanent UK resident?"></asp:Label>
        <asp:DropDownList ID="uxResident" runat="server" SelectedValue='<%# Bind("Resident") %>'>
                <asp:ListItem Value="0" Text="0" />
                <asp:ListItem Value="1" Text="1" />
                <asp:ListItem Value="2" Text="2" />
                <asp:ListItem Value="3" Text="3" />
                <asp:ListItem Value="4" Text="4" />
                <asp:ListItem Value="5" Text="5" />
                <asp:ListItem Value="6" Text="6" />
                <asp:ListItem Value="7" Text="7" />
                <asp:ListItem Value="8" Text="8" />
                <asp:ListItem Value="9" Text="9 or over" />
            </asp:DropDownList>

        <asp:Label ID="uxHowOftenLabel" runat="server" AssociatedControlID="uxHowOften" Text="How often will this driver use the vehicle?"></asp:Label>
            <asp:DropDownList ID="uxHowOften" runat="server" SelectedValue='<%# Bind("HowOften") %>'>
                <asp:ListItem Value="" Text="Please Select" />
                <asp:ListItem Value="1" Text="Not Main User (frequent)" />
                <asp:ListItem Value="2" Text="Main User" />
                <asp:ListItem Value="3" Text="Infrequent (casual)" />
            </asp:DropDownList>

        <asp:Label ID="uxHomeownerLabel" runat="server" AssociatedControlID="uxHomeowner" Text="Is this driver a homeowner?"></asp:Label>
            <asp:DropDownList ID="uxHomeowner" runat="server" SelectedValue='<%# Bind("Homeowner") %>'>
                <asp:ListItem Value="" Text="Please Select" />
                <asp:ListItem Value="No" Text="No" />
                <asp:ListItem Value="Yes" Text="Yes" />
            </asp:DropDownList>

        <asp:Label ID="uxNumOfCarsLabel" runat="server" AssociatedControlID="uxNumOfCars" Text="Does this driver have access to any other cars within the household?" />
        <asp:DropDownList ID="uxNumOfCars" runat="server" SelectedValue='<%# Bind("NumOfCars") %>'>
            <asp:ListItem Value="0" Text="0" />
            <asp:ListItem Value="1" Text="1" />
            <asp:ListItem Value="2" Text="2" />
            <asp:ListItem Value="3" Text="3" />
            <asp:ListItem Value="4" Text="4" />
            <asp:ListItem Value="5" Text="5" />
            <asp:ListItem Value="6" Text="6" />
            <asp:ListItem Value="7" Text="7" />
            <asp:ListItem Value="8" Text="8" />
            <asp:ListItem Value="9" Text="9 or over" />
        </asp:DropDownList>
        <div class="clear"></div>    

        <asp:Label ID="uxCarsOwnedLabel" runat="server" AssociatedControlID="uxCarsOwned" Text="Does this driver own any other cars?" />
        <asp:DropDownList ID="uxCarsOwned" runat="server" SelectedValue='<%# Bind("CarsOwned") %>'>
            <asp:ListItem Value="0" Text="0" />
            <asp:ListItem Value="1" Text="1" />
            <asp:ListItem Value="2" Text="2" />
            <asp:ListItem Value="3" Text="3" />
            <asp:ListItem Value="4" Text="4" />
            <asp:ListItem Value="5" Text="5" />
            <asp:ListItem Value="6" Text="6" />
            <asp:ListItem Value="7" Text="7" />
            <asp:ListItem Value="8" Text="8" />
            <asp:ListItem Value="9" Text="9 or over" />
        </asp:DropDownList>
        <div class="clear"></div>    

        <asp:Label ID="uxClaimFreeLabel" runat="server" AssociatedControlID="uxClaimFree" Text="How many claim free years of driving other cars does this driver have" />
        <asp:DropDownList ID="uxClaimFree" runat="server" SelectedValue='<%# Bind("ClaimFree") %>'>
            <asp:ListItem Value="0" Text="0" />
            <asp:ListItem Value="1" Text="1" />
            <asp:ListItem Value="2" Text="2" />
            <asp:ListItem Value="3" Text="3" />
            <asp:ListItem Value="4" Text="4" />
            <asp:ListItem Value="5" Text="5" />
            <asp:ListItem Value="6" Text="6" />
            <asp:ListItem Value="7" Text="7" />
            <asp:ListItem Value="8" Text="8" />
            <asp:ListItem Value="9" Text="9 or over" />
        </asp:DropDownList>
        <div class="clear"></div>  

        <asp:Label ID="uxRefusedLabel" runat="server" AssociatedControlID="uxRefused" Text="Has this driver ever had insurance refused, cancelled, premiums increased, or conditions imposed?"></asp:Label>
        <asp:DropDownList ID="uxRefused" runat="server" SelectedValue='<%# Bind("Refused") %>'>
                <asp:ListItem Value="" Text="Please Select" />
                <asp:ListItem Value="No" Text="No" />
                <asp:ListItem Value="Yes" Text="Yes" />
            </asp:DropDownList>

        <asp:Label ID="uxOtherConvictionsLabel" runat="server" AssociatedControlID="uxOtherConvictions" Text="Has this driver ever had any non-motoring criminal convictions or prosecutions pending?"></asp:Label>
            <asp:DropDownList ID="uxOtherConvictions" runat="server" SelectedValue='<%# Bind("OtherConvictions") %>'>
                <asp:ListItem Value="" Text="Please Select" />
                <asp:ListItem Value="No" Text="No" />
                <asp:ListItem Value="Yes" Text="Yes" />
            </asp:DropDownList>

        <asp:Label ID="uxDisabilityLabel" runat="server" AssociatedControlID="uxDisability" Text="Does this driver have any disability or medical condition that could affect their fitness to drive?"></asp:Label>
            <asp:DropDownList ID="uxDisability" runat="server" SelectedValue='<%# Bind("Disability") %>'>
                <asp:ListItem Value="" Text="Please Select" />
                <asp:ListItem Value="No" Text="No" />
                <asp:ListItem Value="Yes" Text="Yes" />
            </asp:DropDownList> 

        <asp:Label ID="uxSubmitLabel" runat="server" AssociatedControlID="uxSubmit" Text="Submit"></asp:Label>
        <asp:LinkButton ID="uxSubmit" runat="server" style="float:left" Text="Submit"  CssClass="blue-button-ctrl med"
                ValidationGroup="AddDriver" CausesValidation="true" CommandName="Insert" OnClick="uxSubmit_Click"  />
        <asp:LinkButton ID="uxUpdateButton" style="float:left" Text="Save changes" 
            runat="server" CssClass="blue-button-ctrl" Visible="false"
            ValidationGroup="AddDriver" CausesValidation="true"  />
        <div class="clear"></div>   

    </InsertItemTemplate>
</asp:FormView>

<asp:ObjectDataSource ID="dsDriverByID" runat="server" InsertMethod="DriverInsert" SelectMethod="GetByDriverID" 
    TypeName="GreenHomeDAL.DriverTableAdapters.DriverTableAdapter">
    <InsertParameters>
        <asp:Parameter Name="DriverType" Type="String" />
        <asp:Parameter Name="SessionID" Type="String" />
        <asp:Parameter Name="StartDate" Type="String" />
        <asp:Parameter Name="EndDate" Type="String" />
        <asp:Parameter Name="Title" Type="String" />
        <asp:Parameter Name="FirstName" Type="String" />
        <asp:Parameter Name="Surname" Type="String" />
        <asp:Parameter Name="DateOfBirth" Type="String" />
        <asp:Parameter Name="Gender" Type="String" />
        <asp:Parameter Name="Relationship" Type="String" />
        <asp:Parameter Name="MaritalStatus" Type="String" />
        <asp:Parameter Name="EmploymentStatus" Type="String" />
        <asp:Parameter Name="Occupation" Type="String" />
        <asp:Parameter Name="Business" Type="String" />
        <asp:Parameter Name="SecondaryEmploymentStatus" Type="String" />
        <asp:Parameter Name="SecondaryOccupation" Type="String" />
        <asp:Parameter Name="SecondaryBusiness" Type="String" />
        <asp:Parameter Name="LicenceType" Type="String" />
        <asp:Parameter Name="TimeHeld" Type="String" />
        <asp:Parameter Name="ClassSelect" Type="String" />
        <asp:Parameter Name="Convictions" Type="String" />
        <asp:Parameter Name="Claims" Type="String" />
        <asp:Parameter Name="Resident" Type="String" />
        <asp:Parameter Name="HowOften" Type="String" />
        <asp:Parameter Name="Homeowner" Type="String" />
        <asp:Parameter Name="NumOfCars" Type="String" />
        <asp:Parameter Name="CarsOwned" Type="String" />
        <asp:Parameter Name="ClaimFree" Type="String" />
        <asp:Parameter Name="Refused" Type="String" />
        <asp:Parameter Name="OtherConvictions" Type="String" />
        <asp:Parameter Name="Disability" Type="String" />
        <asp:Parameter Name="DriverSession" Type="String" />
        <asp:Parameter Name="EntryType" Type="String" />
    </InsertParameters>
</asp:ObjectDataSource>

And the c# side:

 protected void PopulateDateFields()
        {
            int startYear = 1900;
            DropDownList uxDay = (DropDownList)uxDriverByID.FindControl("uxDay");
            DropDownList uxMonth = (DropDownList)uxDriverByID.FindControl("uxMonth");
            DropDownList uxYear = (DropDownList)uxDriverByID.FindControl("uxYear");

            uxYear.Items.Clear();
            uxMonth.Items.Clear();
            uxDay.Items.Clear();
            ListItem dayItem = new ListItem("DD", "0");
            ListItem monthItem = new ListItem("MM", "0");
            ListItem yearItem = new ListItem("YYYY", "0");
            uxDay.Items.Add(dayItem);
            uxMonth.Items.Add(monthItem);
            uxYear.Items.Add(yearItem);
            for (int i = (DateTime.Now.Year - 15); i >= startYear; i--)
            {
                uxYear.Items.Add(new ListItem(i.ToString(), i.ToString()));
            }
            for (int i = 0; i < 12; i  )
            {
                string num = i.ToString();
                if (num.Length == 1)
                    num = "0"   num;
                string month = CultureInfo.CurrentUICulture.DateTimeFormat.MonthNames[i];
                uxMonth.Items.Add(new ListItem(month, num));
            }
            for (int i = 1; i <= 31; i  )
            {
                string num = i.ToString();
                if (num.Length == 1)
                    num = "0"   num;
                uxDay.Items.Add(new ListItem(num, num));
            }
            uxDay.DataTextField = "Day";
            uxDay.DataValueField = "Day";
            uxMonth.DataTextField = "Month";
            uxMonth.DataValueField = "Month";
            uxYear.DataTextField = "Year";
            uxYear.DataValueField = "Year";
        }   
  

Я планировал использовать код в событии ItemInserting, но он входит только в то, что для autopostback установлено значение false, поэтому в нем пока ничего нет.

Спасибо

Комментарии:

1. Какие-либо данные даже отправляются на сервер? Поместите точку останова в код отправки (), который запускает ваша кнопка. Таким образом, вы можете быть уверены, что проблема не находится дальше в стеке вашего приложения. Сообщите нам результаты.

2. Хорошо, он достигает точки останова в событии Submit_Click, и все элементы управления имеют данные даже с autopostback= true . Это то, что вы имели в виду?

3. Пожалуйста, опубликуйте разметку и код для FormView и связанных обработчиков источника данных и / или событий, которые вы ожидаете выполнить для выполнения вставки.

4. Это код formview, добавленный сейчас в исходное сообщение..

5. Правильно, если я удалю все параметры из DropDownList , тогда он будет работать с autopostback. Как только я добавляю ListItem, он перестает работать. Подумал, что эта информация может быть полезной

Ответ №1:

В конце совершенно не связанный ответ, и на самом деле довольно непонятный.

У меня есть загрузочный gif рядом с выпадающим списком autopostback, который в CSS задан как:

 #loading_gif{
    visibility:hidden;
}
  

в javascript у меня есть эта функция:

 function showLoading(id)
{    
    document.getElementById(id).style.visibility = 'visible';
    setTimeout('document.images["loading-gif"].src="Assets/Images/eee-loader.gif"', 50); 
}
  

Когда я изменил его на display:block и display:none , вместо visibility , вставка formview работает отлично.
Ну, это исправлено. Если кто-нибудь может пролить свет на то, почему это может произойти, тогда отлично, но пока это работает, я счастлив. Спасибо