Beispiel #1
0
 /// <summary>
 /// Close sheets
 /// </summary>
 private void closeAllSheets()
 {
     for (int i = 0; i < this.lvFacilityResult.Items.Count; i++)
     {
         ucFacilitySheet control = (ucFacilitySheet)this.lvFacilityResult.Items[i].FindControl("ucFacilitySheet");
         if (control != null)
         {
             control.Visible = false;
         }
     }
 }
    protected void OnItemCommand(object sender, ListViewCommandEventArgs e)
    {
        // sorting
        if (e.CommandName == "Sort")
        {
            // set arrows
            setArrows(e.CommandArgument.ToString());

            sort(e.CommandArgument.ToString());
            return;
        }

        // get rowindex
        ListViewDataItem dataItem = e.Item as ListViewDataItem;

        if (dataItem == null)
        {
            return;                   //safe check
        }
        string source = e.CommandSource.ToString();
        string arg    = e.CommandArgument.ToString();

        int rowindex = dataItem.DataItemIndex - PageIndex;

        if (rowindex >= 0 && rowindex < this.lvFacilityResult.Items.Count)
        {
            ucFacilitySheet control = (ucFacilitySheet)this.lvFacilityResult.Items[rowindex].FindControl("ucFacilitySheet");

            if (arg.Equals("togglesheet"))
            {
                closeAllSheets(); // only allow one sheet to be open

                control.Visible = !control.Visible;
                Control div = this.lvFacilityResult.Items[rowindex].FindControl("subsheet");
                div.Visible = !div.Visible;

                if (control.Visible)
                {
                    string facilityReportID = e.CommandName; //name holds the unique facility report ID
                    control.Populate(facilityReportID);
                }
            }
        }
    }