Is this a FormView bug?

tiovoihy

New Member
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 \[code\]NextPreviousFirstLast\[/code\], the update fails.Here's my FormView with it's data sources:\[code\]<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='http://stackoverflow.com/questions/12611347/<%# 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="&lt;&lt; First" LastPageText="Last &gt;&gt;" NextPageText="Next &gt;" PreviousPageText="&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>\[/code\]And here's both of my LinqDataSource's \[code\]Selecting\[/code\] events:\[code\]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 });}\[/code\]I've traced the problem to these lines:\[code\]<PagerSettings Mode="NextPreviousFirstLast" FirstPageText="&lt;&lt; First" LastPageText="Last &gt;&gt;" NextPageText="Next &gt;" PreviousPageText="&lt; Prev" Position="TopAndBottom" />\[/code\]As soon as I remove the above \[code\]PagerSettings\[/code\] 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.
 
Back
Top