Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8601621
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:53:11+00:00 2026-06-12T01:53:11+00:00

I have a FormView (with paging enabled) that is bound to a LinqDataSource on

  • 0

I have a FormView (with paging enabled) that is bound to a LinqDataSource on an ASP.NET page. I’m experiencing some very weird behavior and can’t figure out why it’s happening. For simplicity sake on this question I have removed some unneeded code (other FormView templates, etc) to demonstrate this behavior.

My FormView has 3 fields, two textboxes and one DropDownList. The DropDownList is bound to another LinqDataSource on the page and contains foreign key values. When the FormView’s LinqDataSource only contains one record and I try to update it, the update fails because the selected value of the DropDownList is always empty, no matter which value I pick for it. When the FormView’s LinqDataSource contains 2 or more records, it works as it should.

Now here’s the really weird thing. The update is actually failing because of the FormView’s PagerSettings! When I use just the default Pager settings, all is well. When I change the PagerMode to NextPreviousFirstLast, the update fails.

Here’s my FormView with it’s data sources:

<asp:FormView ID="fvData" runat="server" AllowPaging="True" 
    DataKeyNames="ID" DataSourceID="ldsData" DefaultMode="Edit">
    <EditItemTemplate>
        <table class="pad5">
            <tr>
                <td class="field-name">AREA:</td>
                <td>
                    <asp:DropDownList ID="cboAREA" runat="server" DataTextField="AREA_NAME" 
                        DataValueField="AREA1" SelectedValue='<%# Bind("AREA") %>' DataSourceID="ldsAreas" />
                </td>
            </tr>
            <tr>
                <td class="field-name">LOOP:</td>
                <td><asp:TextBox ID="txtLOOP" runat="server" Text='<%# Bind("LOOP") %>' /></td>
            </tr>
            <tr>
                <td class="field-name">LOOP DESCRIPTION:</td>
                <td><asp:TextBox ID="txtLOOP_DESCRIPTION" runat="server" 
            Text='<%# Bind("LOOP_DESCRIPTION") %>' style="width: 600px" /></td>
            </tr>
        </table>

        <asp:Button ID="btnUpdate" runat="server" Text="Update" CommandName="Update" CausesValidation="True" />
        <asp:Button ID="btnCancel" runat="server" Text="Cancel" CommandName="Cancel" CausesValidation="False" />
    </EditItemTemplate>
    <PagerSettings Mode="NextPreviousFirstLast" 
        FirstPageText="&amp;lt;&amp;lt; First" LastPageText="Last &amp;gt;&amp;gt;" 
        NextPageText="Next &amp;gt;" PreviousPageText="&amp;lt; Prev" 
        Position="TopAndBottom" />
    <PagerStyle CssClass="pager" />
</asp:FormView>

<asp:LinqDataSource ID="ldsData" runat="server" 
    ContextTypeName="E_and_I.EAndIDataDataContext" EnableDelete="True" 
    EnableInsert="True" EnableUpdate="True" EntityTypeName="" 
    TableName="INSTRUMENT_LOOP_DESCRIPTIONs" onselecting="ldsData_Selecting" OrderBy="ID ASC" >
</asp:LinqDataSource>

<asp:LinqDataSource ID="ldsAreas" runat="server" 
    ContextTypeName="E_and_I.EAndIDataDataContext" EntityTypeName="" 
    TableName="AREAs" onselecting="ldsAreas_Selecting">
</asp:LinqDataSource>

And here’s both of my LinqDataSource’s Selecting events:

EAndIDataDataContext db = new EAndIDataDataContext();

protected void ldsData_Selecting(object sender, LinqDataSourceSelectEventArgs e)
{
    e.Result = db.INSTRUMENT_LOOP_DESCRIPTIONs.Take(1); // we only want one record for testing
}

protected void ldsAreas_Selecting(object sender, LinqDataSourceSelectEventArgs e)
{
    e.Result = db.AREAs.OrderBy(a => a.AREA1).Select(a => new { AREA1 = a.AREA1, AREA_NAME = "(" + a.AREA1 + ") " + a.AREA_NAME });
}

I’ve traced the problem to these lines:

<PagerSettings Mode="NextPreviousFirstLast" 
    FirstPageText="&amp;lt;&amp;lt; First" LastPageText="Last &amp;gt;&amp;gt;" 
    NextPageText="Next &amp;gt;" PreviousPageText="&amp;lt; Prev" 
    Position="TopAndBottom" />

As soon as I remove the above PagerSettings element, the FormView updates the record just fine! Does anybody know why the hell the pager settings would have anything to do with this? I’m using the .NET Framework 4.0.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T01:53:12+00:00Added an answer on June 12, 2026 at 1:53 am

    I copied part of your code and I made an experiment and I think, I’m experimenting the same behavior.

    This is what I did:

    <asp:LinqDataSource runat="server" ID="lds"
        TableName="jobs" ContextTypeName="WebApplication2.DataAccess.PubsDataContext" >
    
    </asp:LinqDataSource>
    <asp:LinqDataSource runat="server" ID="ldse"
        TableName="employee" ContextTypeName="WebApplication2.DataAccess.PubsDataContext" OnSelecting="ldse_Selecting">
    
    </asp:LinqDataSource>
    
    <asp:FormView runat="server" DefaultMode="Edit" ClientIDMode="Predictable" DataKeyNames="emp_id" DataSourceID="ldse"
        AllowPaging="true" OnItemCommand="Unnamed_ItemCommand" ID="formView">
        <EditItemTemplate>
            <div>
                <asp:DropDownList runat="server" ID="ddlJobs" DataSourceID="lds" DataTextField="job_desc" DataValueField="job_id">
                </asp:DropDownList>
            </div>
            <div>
                <asp:TextBox runat="server" TextMode="MultiLine" ID="txtDesc" />
            </div>
            <div>
                <asp:Button Text="Save" runat="server" CommandName="Save" CausesValidation="true" />
                <asp:Button Text="Cancel" runat="server" CommandName="Cancel" CausesValidation="false" />
            </div>
        </EditItemTemplate>
        <PagerSettings Mode="NextPreviousFirstLast" 
            FirstPageText="&amp;lt;&amp;lt; First" LastPageText="Last &amp;gt;&amp;gt;" 
            NextPageText="Next &amp;gt;" PreviousPageText="&amp;lt; Prev" 
            Position="TopAndBottom" />
    

    These are my observations:

    • If the FormView contains only one row, then the FormView behaves weird and my commands do not work as expected.

      • My Save command is never fired, instead the `Cancel command is fired

      • My Cancel command causes my FormView to disappear…

    First I thought this was because of the &amp; characters, but this is not the case

    I narrowed the problem to Position="TopAndBottom"

    • If you set the Position attribute to:

      • Top

      • TopAndBottom

      You will experiment the same problem. (As you mention probably a bug)

    • If you set the Position attribute to:

      • Buttom

      It works as expected

    To be honest, if this is a bug, I can’t believe none else has found it and report it.

    I made the same experiment with Visual Studio 2012 for Web (ASP.NET 4.5) and I’m experimenting the exact same behavior…

    This makes me think that probably I’m doing something fundamentally wrong and perhaps this is not a bug and that’s why I’m experimenting the same behavior with both versions ASP.NET 4 and ASP.NET 4.5, but if that’s the case, I simply can’t figure out what is it.

    On the other hand, if this is a bug, the same bug will be present in ASP.NET 4.5

    Edit 1

    I uploaded the code to my GitHub site for reference

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a ASP.NET page with a FormView control. When the FormView is bound
I am using a LinqDataSource and a FormView with paging enabled on an ASP.NET
I have a FormView with paging enabled. The FormView is bound to an EntityDataSource
I have a FormView control in an ASP.NET page. I use the InsertItemTemplate and
In ASP.NET, I have a FormView which is bound to an ObjectDataSource. The FormView
I have a FormView control in an ASP.NET 2.0 app. I've got the database
I have an asp:FormView control bound to a datasource. Everything is working fine. If
I have FormView in my page markup: <asp:FormView ruanat=server ID=FormView1 DataSourceID=SqlDataSource1 OnDataBinding=FormView1_DataBinding OnDataBound=FormView1_DataBound> <InsertItemTemplate>
I have a ListView inside a FormView that, for some strange reason, doesn't fire
I have been trying to use declarative data bound ASP.NET, and struggling with the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.