コード例 #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        //Request the ID
        String s = Request.QueryString["ID"];

        //Defend against null strings. Makes sense in a debug
        //environment.
        if (s == null)
        {
            s = "2014-45-0001";
        }
        //Set the case ID on top of page
        literalCaseId.Text = s;
        literalCaseId.DataBind();

        //Get the Case object from the ID
        BackEnd backEnd       = new BackEnd();
        Case    requestedCase = backEnd.GetCaseByID(s);

        if (requestedCase == null)
        {
            //TODO: throw meaningful error message.
        }
        //Collect the case in a list bind it as data source
        List <Case> caseList = new List <Case>();

        caseList.Add(requestedCase);
        formViewSpecificCrime.DataSource = caseList;
        formViewSpecificCrime.DataBind();

        //Get the empoyee list and bind
        dropDownEmployees.DataSource = backEnd.GetEmployeeList();
        dropDownEmployees.DataBind();
        dropDownEmployees.Items.Insert(0, new ListItem("Välj alla", "0"));
    }
コード例 #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        //Create instance of backend, get case list and bind data
        BackEnd backEnd = new BackEnd();

        gridViewCrimes.DataSource = backEnd.GetCaseList();
        gridViewCrimes.DataBind();

        //Get status list, bind it and make "välj alla" first
        //default option.
        dropDownStatus.DataSource = backEnd.GetStatusList();
        dropDownStatus.DataBind();
        dropDownStatus.Items.Insert(0, new ListItem("Välj alla", "0"));

        //Get employeelist, bind data and make "välj alla" first
        //default option.
        dropDownInvestigator.DataSource = backEnd.GetEmployeeList();
        dropDownInvestigator.DataBind();
        dropDownInvestigator.Items.Insert(0, new ListItem("Välj alla", "0"));
    }