The EntitySpaces Community

Share and learn about the EntitySpaces Architecture.
Welcome to The EntitySpaces Community Sign in | Join | Help
in
Home Forums Photos

esDataSoure in Form View --> Need Some Intial Coding

Last post 03-03-2008, 8:28 AM by Mike.Griffin. 3 replies.
Sort Posts: Previous Next
  •  03-01-2008, 5:23 AM 8222

    esDataSoure in Form View --> Need Some Intial Coding

    protected void Page_Load(object sender, EventArgs e)

    {

    if (!this.Page.IsPostBack)

    {

    EmpLookup emp1 = new EmpLookup();

    //MainPageBannerLayout layout = new MainPageBannerLayout();

    emp1.Query.es.CountAll = true;

    emp1.Query.es.CountAllAlias = "Count";

    EsDataSource2.TotalRowCount = (int)emp.GetColumn("Count");

    emp1.Query.OrderBy(emp1.Query.IiEmpLookupIdPk.Ascending);

    }

    }

    protected void EsDataSource2_esSelect(object sender, EntitySpaces.Web.esDataSourceSelectEventArgs e)

    {

    EmpLookupCollection coll = new EmpLookupCollection();

    // Assign the esDataSourcSelectEvenArgs Collection property

    e.Collection = coll;

    }

    protected void EsDataSource2_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;

    }

    Any other Intial Code need for esDataSoure assign FormView. The above mention code not assign. Please help me. 

    http://community.entityspaces.net/forums/thread/3456.aspx from the following forums its works clear for GridView,DetailView. I need Coding for FormView.

    regard's

    Yogesh Varan

     

     

  •  03-01-2008, 6:24 AM 8223 in reply to 8222

    Re: esDataSoure in Form View --> Need Some Intial Coding

    The only difference in the DetailView control and the FormView control is that the FormView can be templated. See here for more info on this.

    The FormView control is used to display a single record from a data source. It is similar to the DetailsView control, except it displays user-defined templates instead of row fields. Creating your own templates gives you greater flexibility in controlling how the data is displayed.


    Regards,

    Scott Schecter
    EntitySpaces | My Site
  •  03-03-2008, 12:50 AM 8230 in reply to 8223

    Re: esDataSoure in Form View --> Need Some Intial Coding

    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 

     

     

     

     

  •  03-03-2008, 8:28 AM 8235 in reply to 8230

    Re: esDataSoure in Form View --> Need Some Intial Coding

    My guess is your ASPX page has a column name in it in text "likethis" that is spelled with a different case than the property, thus its not being found in the dictionary. Also, use the "Code" button when posting code, it's the last toolbar button on the right when posting code.

    See the post http://community.entityspaces.net/forums/thread/7427.aspx

     


    EntitySpaces | Twitter | BLOG | Please honor our Software License
View as RSS news feed in XML