简体   繁体   English

如果autopostback = true,则Formview插入不起作用。 asp.net

[英]Formview insert not working if autopostback=true. asp.net

I have a page with a dropdownlist that has a selectedIndexChanged event attached. 我有一个带有dropdownlist的页面,该页面附加了selectedIndexChanged事件。 So, for each option in the dropdownlist , there is a usercontrol that contains a form relevant to that section. 因此,对于dropdownlist每个选项,都有一个usercontrol ,其中包含与该部分相关的表单。 (each user control is in a panel, and the selectedIndexChanged event toggles visibility of that panel. (每个用户控件都在面板中,并且selectedIndexChanged事件可切换该面板的可见性。

However, for one of the forms, I am inserting the data into SQL Server, so have used a formview, only the trouble was it wasn't inserting. 但是,对于其中一种表单,我将数据插入到SQL Server中,因此使用了formview,唯一的麻烦是没有插入。

After spending ages stripping back the page to find out the point of failure, it turns out that it is the AutoPostBack="true " on the dropdownlist that is causing the problem. 经过花了很长时间才剥离页面以找出故障点,事实证明, dropdownlist中的AutoPostBack="true ”才是导致问题的原因。 Even when I remove all other panels/usercontrols, and making it so the formview panel is visible all the team (meaning that the dropdownlist is not changed and therefore no pastback happens) it still just fails. 即使我删除了所有其他面板/用户控件,并使formview面板在整个团队中都可见(这意味着dropdownlist未更改,因此没有发生回退),但它仍然只是失败。 If I remove that from the dropdown, the data inserts no problem. 如果我从下拉列表中删除该数据,则数据不会出现问题。

Has anyone seen this before, or can think of a logical reason why this might be happening? 有没有人看过这个,或者可以想到一个逻辑上的原因呢?

I'll post up the code of the dropdown just in case it helps: 我将发布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>

UPDATE - as requested, here is the code for the formview insert: 更新-根据要求,这是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";
        }   

I did plan to have code in the ItemInserting event, but it only goes into that with autopostback set to false, so nothing in it yet. 我确实计划在ItemInserting事件中包含代码,但是只有在autopostback设置为false的情况下,它才会出现在代码中,因此还没有任何内容。

Thanks 谢谢

Completely unrelated answer in the end, and quite baffling really. 最后的答案完全无关,而且确实令人困惑。

I have a loading gif next to the autopostback dropdownlist, which in the CSS, is set as: 我在autopostback下拉列表旁边有一个加载gif,在CSS中,该列表设置为:

#loading_gif{
    visibility:hidden;
}

in the javascript, I've got this function: 在javascript中,我有以下功能:

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

When I changed it to display:block and display:none , instead of visibility , the formview insert works perfectly. 当我将其更改为display:blockdisplay:none ,而不是visibility ,formview插入可以完美地工作。
Ah well it's fixed. 嗯,它是固定的。 If anyone can shed any light on why that might happen then great, but as long as it's working then I'm happy. 如果有人能阐明为什么会发生这种情况,那就太好了,但是只要它能正常工作,我就会很高兴。 Thanks 谢谢

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM