2011-03-16 7 views
2

주소 사용자 컨트롤이 있습니다.사용자 정의 간단한 데이터 바인딩 - ASP.NET

<fieldset> 
    <legend><%#Title%></legend> 
<div> 
<div>Country</div> 
    <div><uc:TextBox ID="txtCountry" runat="server" /></div> 
</div> 


<div> 
<div>City</div>  
    <div><uc:TextBox ID="txtCity" runat="server" /></div> 
</div> 


<div> 
<div>Street</div>  
    <div><uc:TextBox ID="txtStreet" runat="server"/></div> 
</div> 
</fieldset> 

그리고

private BEAddress _address; 
    public BEAddress Address 
    { 

     get 
     { 
      if (CoordinatesVisible) 
      { 
       _address = new BEAddress() 
       { 
        Country = txtCountry.Text, 
        City = txtCity.Text, 
        Street = txtStreet.Text, 
        Block = txtBlock.Text, 
        Building = txtBuilding.Text, 

        Latitude = txtLatitude.Text, 
        Longitude = txtLongitude.Text 
       }; 
      } 
      else 
      { 
       _address = new BEAddress() 
       { 
        Country = txtCountry.Text, 
        City = txtCity.Text, 
        Street = txtStreet.Text, 
        Block = txtBlock.Text, 
        Building = txtBuilding.Text 

       }; 
      } 
      return _address; 
     } 


     set 
     { 
      if (CoordinatesVisible) 
      { 
       _address = new BEAddress() 
       { 
        Country = value.Country, 
        City = value.City, 
        Street = value.Street, 
        Block = value.Block, 
        Building = value.Building, 

        Latitude = value.Latitude, 
        Longitude = value.Longitude 
       }; 
      } 
      else 
      { 
       _address = new BEAddress() 
       { 
        Country = value.Country, 
        City = value.City, 
        Street = value.Street, 
        Block = value.Block, 
        Building = value.Building, 

        Latitude = value.Latitude, 
        Longitude = value.Longitude 
       }; 
      } 
     } 

    } 

어떻게 간단한 데이터 바인딩해야합니까 숨김

? 난 당신이 내가 전혀 좋아하지 않는 DetailsView 마녀를 사용하려는 경우가 아니면 아무것도 ASP.NET에서 상자 밖으로 없다이

<uc:Address runat="server" ID="uc1" Address=<%#GetAddress %> /> 

답변

1

같은 싶어요.

제 프로그램의 경우 저에게 일반적인 방식으로 바인딩을 관리하는 클래스를 작성했습니다. 개념은 컨트롤 속성을 개체 속성에 바인딩하는 것이 었습니다.

관련 문제