When I try to Update or Delete a single selected item, it throws a
"Row not found or changed." exception. Basically I only did a linq query and use most of the auto-generate function. Add
LinqDataSource1_ContextCreated
function,does not help.
Please help me! Thanks in advance!
</asp:GridView>
<asp:LinqDataSource ID="LinqDataSource1" runat="server"
ContextTypeName="JobPostDataContext"
EntityTypeName=""
onselecting="LinqDataSource1_Selecting"
TableName="JobLists"
EnableDelete="True"
EnableUpdate="True" >
</asp:LinqDataSource>
protected void LinqDataSource1_Selecting(object sender, LinqDataSourceSelectEventArgs e)
{
JobPostDataContext db = new JobPostDataContext();
var query = from uM in db.aspnet_Memberships
join uD in db.UserDetails
on uM.UserId equals uD.UserId
join u in db.aspnet_Users
on uM.UserId equals u.UserId
join jL in db.JobLists
on uM.UserId equals jL.UserId
where u.UserName == Request.QueryString["UserName"]
select new {jL.JobId, jL.JobTitle, jL.Summary, jL.Detail, jL.CompanyName,
jL.CompanyEmail, jL.PostDate, jL.IsTop, jL.IsShown, u.UserName};
e.Result = query;
}
protected void LinqDataSource1_ContextCreated(object sender, LinqDataSourceStatusEventArgs e)
{
JobPostDataContext db = e.Result as JobPostDataContext;
System.Data.Linq.DataLoadOptions dl = new System.Data.Linq.DataLoadOptions();
dl.LoadWith<JobList>(d => d.JobId); d
b.LoadOptions = dl;
}
Row not found or changed. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.Linq.ChangeConflictException: Row not found or changed.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[ChangeConflictException: Row not found or changed.] System.Data.Linq.ChangeProcessor.SubmitChanges(ConflictMode failureMode) +996823 System.Data.Linq.DataContext.SubmitChanges(ConflictMode failureMode) +378 System.Data.Linq.DataContext.SubmitChanges() +23 System.Web.UI.WebControls.LinqToSqlWrapper.SubmitChanges(DataContext dataContext) +9 System.Web.UI.WebControls.LinqDataSourceView.UpdateDataObject(Object dataContext, Object table, Object oldDataObject, Object newDataObject) +115 System.Web.UI.WebControls.LinqDataSourceView.UpdateObject(Object oldEntity, Object newEntity) +262 System.Web.UI.WebControls.QueryableDataSourceView.ExecuteUpdate(IDictionary keys, IDictionary values, IDictionary oldValues) +115 System.Web.UI.WebControls.ContextDataSourceView.ExecuteUpdate(IDictionary keys, IDictionary values, IDictionary oldValues) +100 System.Web.UI.WebControls.LinqDataSourceView.ExecuteUpdate(IDictionary keys, IDictionary values, IDictionary oldValues) +41 System.Web.UI.DataSourceView.Update(IDictionary keys, IDictionary values, IDictionary oldValues, DataSourceViewOperationCallback callback) +95 System.Web.UI.WebControls.GridView.HandleUpdate(GridViewRow row, Int32 rowIndex, Boolean causesValidation) +1226 System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +716 System.Web.UI.WebControls.GridView.OnBubbleEvent(Object source, EventArgs e) +95 System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37 System.Web.UI.WebControls.GridViewRow.OnBubbleEvent(Object source, EventArgs e) +121 System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37 System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) +125 System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +169 System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +9 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +176 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5563
[edit]Formatting sorted out so it was readable - OriginalGriff[/edit]