2016-12-16 1 views
0

내 combobox 내, 내 combobox 호출 할 수 있지만 C#에서 combobox ID를 입력 할 때 개체가 현재 컨텍스트에서 존재하지 않습니다.어떻게 호출/액세스 제어 콤보 상자 asp devexpress

informatition을 내 gridview에 내가 3 데이터 소스를 설정하려면 3 데이터 소스 내 콤보를 영문의 gridview에서

protected void btnShow_Click(object sender, EventArgs e) 
    { 
     string ddl = ddlApp.Value.ToString(); 
     if (ddl == "ATTD") 
     { 
      GvMenu.DataSourceID = "SqlDataSourceAttd"; 
      GvMenu.DataBind(); 
     } 
     else if (ddl == "TRVL") 
     { 
      GvMenu.DataSourceID = "SqlDataSourceTrvl"; 
      GvMenu.DataBind(); 
     } 
     else if (ddl == "CORE") 
     { 
      GvMenu.DataSourceID = "SqlDataSourceCore"; 
      GvMenu.DataBind(); 
     } 
    } 

(3 조건부 데이터 소스와이 세 조건 콤보 상자 데이터 소스 1 개의 gridview가)

[! 코드 [조각 내있는 gridview를] [1] [1]

<dx:GridviewDataComboboxcolumn FieldName="ParentMenuID" visibleindex="2" Caption="Parent Menu ID" showincustomizationform="true" > 

      <PropertiesComboBox ValueField="ParentMenuID" TextField="ParentMenuID" ValueType="System.String" > 
      </PropertiesComboBox> 

     </dx:GridviewDataComboboxcolumn> 
+0

코드를 이미지가 아닌 텍스트로 삽입하는 것이 좋습니다. 이유는 단순히 이미지의 코드를 복사하여 답안에서 편집 할 수 없기 때문입니다. 필요한 수정을 설명하려면 이미지에서 코드를 다시 입력해야합니다. – Uranus

답변

0

셀 템플릿에 ASPxComboBox 및 ASPxLabel 구성 요소 만 사용하고있는 것으로 나타났습니다. GridViewDataComboBoxColumn을 사용하면 동일한 결과를 얻을 수 있습니다.

<dx:GridViewDataComboBoxColumn FieldName="ParentMenuID"> 
    <PropertiesComboBox ValueType="System.String" /> 
</dx:GridViewDataComboBoxColumn> 

if (ddl == "ATTD") 
{ 
    var parentMenuColumn = (GridViewDataComboBoxColumn)GvMenu.Columns["ParentMenuID"]; 
    parentMenuColumn.PropertiesComboBox.DataSourceID = "Your Data Source ID"; 
    GvMenu.DataSourceID = "SqlDataSourceAttd"; 
    GvMenu.DataBind(); 
} 
+0

에서 데이터 소스를 변경하는 올바른 방법을 찾기위한 추가 예와 DevExpress의 스레드를 확인하시기 바랍니다 무엇을 단계별로 제공 할 수 있습니다 "PropertiesComboBox"의 오류 " "에 "PropertiesComboBox"에 대한 정의가없고 확장 메서드가 없습니다 ..... –

+0

GvMenu.Columns [index]가 기본 클래스의 인스턴스를 반환합니다. 그에 따라 내 대답을 업데이 트했습니다. – Uranus

+0

많이 thx. –

0

열의 DataItemTemplate 컨테이너에있는 컨트롤을 찾으려면 ASPxGridView.FindRowCellTemplateControl 메서드를 사용해야합니다. Accessing Controls Contained within Templates 주제를 참조하십시오.

컨트롤을 사용자 지정하는 가장 좋은 장소는 Init 및 Load 이벤트이며 이러한 이벤트는 컨트롤 초기화 (Init 및 Load)에 사용해야합니다.
The general technique of using the Init/Load event handler

다음을 참조하십시오 :
Find controls in the DataItem template of ASPxGridView column
How to Find DataItemTemplate control inside OnCustomButtonCallback event using c# in server side
ASPxGridView - How to find a control inside the DataItem template

을 런타임에 그리드의 데이터 소스를 변경하는 경우 :
ASPxGridView - How to change datasources for the grid
ASPxGridView - How to change Datasource at runtime

How to dynamically switch the grid's data source and recreate columns at runtime

런타임에 데이터 소스를 전환하는 방법을 보여줍니다 강령 중앙, 에서 How to dynamically switch the grid's data source and recreate columns at runtime 예를 검토하십시오. 이 샘플에 언급 된 다른 예제를 검토하는 것이 좋습니다 ( ).

+0

나는 그 모든 것을 읽었지 만 쉬운 예를 찾고있다. –

+0

그런 다음 콤보 상자의 Init 이벤트를 사용하면 요구 사항에 따라 할 수있는 올바른 장소가 될 것이다. –

+0

다른 예를 들어 줄 수 있습니까? devexpress에 대한 초보자 xx 많이 –