2011-01-18 2 views
2

나는 데이터 쿼리에서 동적으로 생성 된 테이블 배열을 가지고 있으며 세션 변수에 저장되어 있습니다. 이제는 텍스트 상자를 추가하여 한 번에 표시 할 행 수를 제한하고 싶습니다. 이를 테스트하기 위해 두 개의 버튼 메서드를 작성했습니다. 하나는 일부 행을 visible = false로 설정하고 두 번째 버튼 메서드는 동일한 행을 visible = true로 다시 설정합니다.테이블 행 가시성을 변경하는 ASP.net 문제

protected void limit_btn_Click(object sender, EventArgs e) 
{ 
    for (int i = 0; i < traceTables.Length; i++) 
     for (int j = 2; j < traceTables[i].Rows.Count; j++) 
      traceTables[i].Rows[j].Visible = false; 

    Session["Tables"] = traceTables; 
    table_C(); 
}//end limit_btn_Click() 

protected void obo_btn_Click(object sender, EventArgs e) 
{ 
    for (int i = 0; i < traceTables.Length; i++) 
     for (int j = 2; j < traceTables[i].Rows.Count; j++) 
      traceTables[i].Rows[j].Visible = true; 

    Session["Tables"] = traceTables; 
    table_C(); 
}//end obo_btn_Click() 

protected void table_C() 
{ 
    String changeTo = log_locations.SelectedValue; 
    for (int i = 0; i < sshLoc.Length; i++) 
    { 
     if (sshLoc[i].CompareTo(changeTo) == 0) 
     { 
      table_panel.ContentTemplateContainer.Controls.Remove(traceTables[currentTable]); 
      System.Diagnostics.Debug.WriteLine("Removing " + sshLoc[currentTable]); 
      table_panel.ContentTemplateContainer.Controls.Add(traceTables[i]); 
      System.Diagnostics.Debug.WriteLine("Adding " + sshLoc[i]); 
      currentTable = i; 
      Session["CurrentTable"] = currentTable; 
      break; 
     }//end if 
    }//end for 
}//end table_C() 

table_C()는 기본적으로 제거하고 패널에서 테이블을 추가 - 내가 (작동) 드롭 다운 목록에서 테이블 사이를 전환 할 때 내가 그것을 사용하고,이 경우에는 단순히 제거하고 동일한 테이블을 추가 패널 내용 컨테이너에서.

문제는 행을 보이지 않게 설정하면 문제가 없다는 것입니다. 행을 다시 볼 수있게 설정하면 안됩니다. 이유는 확실하지 않습니다.

답변

1

ASP : traceTables [i] .Rows [j] .Add ("style", "display : none")에서 display : none 및 display : visible을 사용해보십시오.

표시는 HTML에서 완전히 제거하므로 페이지를 다시 만들어서 다시 표시 할 수 있습니다.

0

테이블이 아닌 목록에 데이터를 저장해야합니다.

행을 표시하지 않도록 설정하면 해당 행이 html 테이블에서 제거됩니다. 그래서 다시 볼 수 있도록 설정할 수 없습니다.

데이터를 별도의 개체에 저장하고 목록에 바인딩하면 표시 여부를 설정하거나 해제 할 수 있습니다.