2009-07-23 8 views
0

한 번 설정하면 GridView .Caption을 변경할 수없는 것처럼 보입니다. 또한 페이지 (와의 GridView - 나는 페이지 미리 렌더링,의 GridView 사전 렌더링에 모든 괜찮을 것 같다 코드에서, 포스트 백 이내에 변경GridView 캡션을 변경할 수 없습니다.

내가 아무 생각이 어디에 있든 무엇을 다음 캡션을 설정하고 나면

) .Caption 디버깅 중에 PreRender 이벤트가 적절하지만 어쨌든 이전 캡션으로 렌더링합니다.

페이지가 한 번 설정되어 캡션이 변경된 것처럼 보입니다.

나는 updatePanel에 배치하고 업데이트하려고했지만 심지어는 도움이되지 못했습니다.

아무도 이유를 제안 할 수 있습니까? 사전에 감사합니다.

답변

1

이 예에서 작동하는 것으로 보입니다. 코드를 게시 할 수 있습니까?

<%@ Page Language="C#" %> 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 

<script runat="server"> 

    protected void Page_Load(object sender, EventArgs e) 
    { 
     if (!IsPostBack) 
     { 
      System.Collections.Generic.List<int> Values = new System.Collections.Generic.List<int> { 1, 2, 3, 4, 5, 6, 7 }; 
      grdTest.DataSource = Values; 
      grdTest.DataBind(); 
     } 
    } 

    protected void btnSubmit_Click(object sender, EventArgs e) 
    { 
     grdTest.Caption = "test grid " + DateTime.Now.ToString(); 


    } 
</script> 

<html xmlns="http://www.w3.org/1999/xhtml"> 
<head runat="server"> 
    <title></title> 
</head> 
<body> 
    <form id="form1" runat="server"> 
    <div> 
      <asp:GridView ID="grdTest" Caption="test grid" runat="server"> 
       <Columns> 
        <asp:TemplateField> 
         <ItemTemplate> 
          hello 
         </ItemTemplate> 
        </asp:TemplateField> 
       </Columns> 
      </asp:GridView> 

      <asp:Button ID="btnSubmit" runat="server" onclick="btnSubmit_Click" Text="Submit" /> 

    </div> 
    </form> 
</body> 
</html> 
+0

코드는 다소 긴하지만 전체 코드에서 .Caption하는 다른 과제가 없습니다 즉,를 Page_Load 에서 호출 관련 부분 의 dgPublications.Caption = 및 String.format ("주문 # {0} 제품 유형 ", _currentOrderID); dgOrderContent.Caption = _currentPubID.HasValue? string.Format ("Order # {0} content", Dictionaries.GetInstance (((MDSPage) this.Page) .Database) .PublicationIDs [_currentPubID.Value]) : string.Format _currentOrderID); dgOrderContent.DataBind(); – igor

+0

viewstate를 해제 했습니까? 데이터 바인드를 해제 한 경우 모든 페이지로드시에이를 설정해야 할 수도 있습니다. –

관련 문제