public
partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!this.Page.IsPostBack)
{
EmpLookup emp = new EmpLookup();
emp.Query.es.CountAll =
true;
emp.Query.es.CountAllAlias =
"Count";
if (emp.Query.Load())
{
this.EsDataSource1.TotalRowCount = (int)emp.GetColumn("Count");
}
this.GridView1.Sort(EmpLookupMetadata.PropertyNames.IiEmpLookupIdPk, SortDirection.Ascending);
}
}
protected void EsDataSource1_esSelect(object sender, EntitySpaces.Web.esDataSourceSelectEventArgs e)
{
EmpLookupCollection coll = new EmpLookupCollection();
// Assign the esDataSourcSelectEvenArgs Collection property
e.Collection = coll;
}
protected void EsDataSource1_esCreateEntity(object sender, EntitySpaces.Web.esDataSourceCreateEntityEventArgs e)
{
EmpLookup entity = new EmpLookup();
if (e.PrimaryKeys != null)
{
entity.LoadByPrimaryKey((
int)e.PrimaryKeys[0]);
}
// Assign the Entity
e.Entity = entity;
}
protected void EsDataSource2_esSelect(object sender, EntitySpaces.Web.esDataSourceSelectEventArgs e)
{
EmpLookupCollection employees = new EmpLookupCollection();
if (EsDataSource2.State.ContainsKey("employeeid"))
{
employees.Query.Where(employees.Query.IiEmpLookupIdPk == (
int)EsDataSource2.State["employeeid"]);
employees.Query.Load();
e.Collection = employees;
}
else
{
e.Collection = employees;
}
}
protected void EsDataSource2_esCreateEntity(object sender, EntitySpaces.Web.esDataSourceCreateEntityEventArgs e)
{
EmpLookup employee = new EmpLookup();
if (e.PrimaryKeys == null)
{
employee.AddNew();
}
else
{
employee.LoadByPrimaryKey((
int)e.PrimaryKeys[0]);
}
e.Entity = employee;
}
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
if (EsDataSource2.State.ContainsKey("employeeid"))
EsDataSource2.State[
"employeeid"] = GridView1.SelectedValue;
else
EsDataSource2.State.Add(
"employeeid", GridView1.SelectedValue);
FormView1.DataBind();
}
protected void FormView1_ItemUpdated(object sender, FormViewUpdatedEventArgs e)
{
GridView1.DataBind();
}
protected void FormView1_ItemInserted(object sender, FormViewInsertedEventArgs e)
{
GridView1.DataBind();
}
protected void FormView1_ItemDeleted(object sender, FormViewDeletedEventArgs e)
{
GridView1.DataBind();
}
The above mention Coding working properly for GridView and FormView. but Update is not working in both GridView and FormView.
for Update its shows error.
Server Error in '/ES_Datasource' Application.
Object reference not set to an instance of an object.
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.NullReferenceException: Object reference not set to an instance of an object.
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:
[NullReferenceException: Object reference not set to an instance of an object.]
EntitySpaces.Web.esDataSourceView.Update(IDictionary keys, IDictionary values, IDictionary oldValues, DataSourceViewOperationCallback callback) +757
System.Web.UI.WebControls.FormView.HandleUpdate(String commandArg, Boolean causesValidation) +1150
System.Web.UI.WebControls.FormView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +461
System.Web.UI.WebControls.FormView.OnBubbleEvent(Object source, EventArgs e) +95
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35
System.Web.UI.WebControls.FormViewRow.OnBubbleEvent(Object source, EventArgs e) +109
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35
System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) +115
System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +163
System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +174
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102 |
Please provide help for me. Any code changes is need for esupdate statement.
regard's
Yogesh Varan