示例#1
0
        //Listing 16-1. Binding a grid view control to LightSwitch data
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack && Request.Params["EngineerId"] != null)
            {
                using (ServerApplicationContext appContext =
                           LightSwitchApplication.ServerApplicationContext.CreateContext())
                {
                    using (DataWorkspace workspace =
                               appContext.Application.CreateDataWorkspace())
                    {
                        Engineer eng =
                            workspace.ApplicationData.Engineers_SingleOrDefault(
                                int.Parse(Request.Params["EngineerID"]));

                        //Set the engineer name label
                        EngineerNameLabel.InnerText = " Issue records for engineer: " + eng.Fullname;

                        //Bind the issues grid
                        IssuesGrid.DataSource = eng.Issues.Where(a => a.Id < 5);
                        IssuesGrid.DataBind();

                        IssuesGrid2.DataSource = eng.Issues.Where(a => a.Id < 5);
                        IssuesGrid2.DataBind();
                    }
                }
            }
        }
示例#2
0
        protected void GetIssues_Click(object sender, EventArgs e)
        {
            ApplicationData srvRef =
                new ApplicationData(new Uri(ServiceEndPointURL.Text));
            var issues = srvRef.Issues.OrderByDescending(item => item.Id).Take(100);

            IssuesGrid.DataSource = issues;
            IssuesGrid.DataBind();
        }
示例#3
0
 private void RebindGrid()
 {
     IssuesGrid.DataSource = Issue;
     IssuesGrid.DataBind();
 }