2010-07-31 5 views
0
<div> 

    <dx:ASPxGridView ID="ASPxGridView1" runat="server" AutoGenerateColumns="False" 
     ClientInstanceName="ASPxGridView1" DataSourceID="LinqServerModeDataSource1" 
     KeyFieldName="ProductID" 
     oncelleditorinitialize="ASPxGridView1_CellEditorInitialize" 
     onrowdeleting="ASPxGridView1_RowDeleting" 
     onrowinserting="ASPxGridView1_RowInserting" 
     onrowupdating="ASPxGridView1_RowUpdating"> 
     <Columns> 
      <dx:GridViewCommandColumn VisibleIndex="0"> 
       <EditButton Visible="True"> 
       </EditButton> 
       <NewButton Visible="True"> 
       </NewButton> 
       <DeleteButton Visible="True"> 
       </DeleteButton> 
      </dx:GridViewCommandColumn> 
      <dx:GridViewDataTextColumn Caption="ProductID" FieldName="ProductID" 
       VisibleIndex="1"> 
      </dx:GridViewDataTextColumn> 
      <dx:GridViewDataTextColumn Caption="ProductName" FieldName="ProductName" 
       VisibleIndex="2"> 
      </dx:GridViewDataTextColumn> 
      <dx:GridViewDataComboBoxColumn Caption="CategoryID" FieldName="CategoryID" 
       VisibleIndex="3"> 
       <PropertiesComboBox DataSourceID="LinqServerModeDataSource2" 
        TextField="CategoryName" ValueField="CategoryID" ValueType="System.Int32"> 
       </PropertiesComboBox> 
      </dx:GridViewDataComboBoxColumn> 
     </Columns> 
    </dx:ASPxGridView> 

</div> 
<dx:LinqServerModeDataSource ID="LinqServerModeDataSource1" runat="server" 
    onselecting="LinqServerModeDataSource1_Selecting" /> 
<dx:LinqServerModeDataSource ID="LinqServerModeDataSource2" runat="server" 
    onselecting="LinqServerModeDataSource2_Selecting" /> 

의 C# 구문을 지원하지 않습니다 :DropDownLists -보기 메시지 지정 방법은

protected void Page_Load(object sender, EventArgs e) 
     { 

     } 

     protected void LinqServerModeDataSource1_Selecting(object sender, DevExpress.Data.Linq.LinqServerModeDataSourceSelectEventArgs e) 
     { 
      NorthWindDataContext db = new NorthWindDataContext(); 
      var r = from p in db.Products 
        select p; 
      e.QueryableSource = r; 
     } 

     protected void ASPxGridView1_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e) 
     { 

     } 

     protected void ASPxGridView1_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e) 
     { 

     } 

     protected void ASPxGridView1_RowDeleting(object sender, DevExpress.Web.Data.ASPxDataDeletingEventArgs e) 
     { 

     } 

     //protected void ASPxGridView1_CellEditorInitialize(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewEditorEventArgs e) 
     //{ 

     //} 

     protected void ASPxGridView1_CellEditorInitialize(object sender, ASPxGridViewEditorEventArgs e) 
     { 
      if (!ASPxGridView1.IsEditing || e.Column.FieldName != "CategoryID") return; 
      ASPxComboBox combo = e.Editor as ASPxComboBox; 

      if (!(e.KeyValue == DBNull.Value || e.KeyValue == null)) //return; 
      { 
       object val = ASPxGridView1.GetRowValuesByKeyValue(e.KeyValue, "CategoryID"); 
       if (val == DBNull.Value) return; 
       Int16 BrokerId = (Int16)val; 
       FillCityCombo(combo, BrokerId); 
      } 

      combo.Callback += new CallbackEventHandlerBase(cmbBranch_OnCallback); 
     } 

     protected void FillCityCombo(ASPxComboBox cmb, Int16 BrokerId) 
     { 
      NorthWindDataContext db = new NorthWindDataContext(); 
      var r = from p in db.Categories 
        where (p.CategoryID == BrokerId) 
        select p; 

      cmb.Items.Clear(); 
      cmb.DataSourceID = ""; 
      cmb.DataSource = r; 
      cmb.DataBind(); 
     } 


     private void cmbBranch_OnCallback(object source, CallbackEventArgsBase e) 
     { 
      FillCityCombo(source as ASPxComboBox, Convert.ToInt16(e.Parameter)); 
     } 


     protected void LinqServerModeDataSource2_Selecting(object sender, DevExpress.Data.Linq.LinqServerModeDataSourceSelectEventArgs e) 
     { 
      NorthWindDataContext db = new NorthWindDataContext(); 
      var r = from p in db.Categories 
        select p; 
      e.QueryableSource = r; 
     } 

실행 코드는 오류 메시지 지정 방법은 지원되지 않습니다 나에게 보여줍니다.

내가 범주를 표시하려면 해당 열을 형성 카테고리 테이블을 표시 할 AspxGridview.CategoryID에서 제품 테이블 정보는 제품 테이블에 배치의 열 중 하나입니다 보여주고 싶어 할 NorthWind database.I를 사용 카테고리 테이블의방법?

왜이 문제를 해결할 수 있습니다. gridview의 명령 필드를 클릭하십시오 CategoryName을 기준으로 CategoryID를 가져오고 싶습니다.

답변

1

Show message Specified method is not supported 오류는 LinqServerModeDataSource.EnableUpdate 속성을 true로 설정하면 해결 될 수 있습니다.

http://search.devexpress.com/?q=Specified+method+is+not+supported.&p=T4|P5|0&d=447

> 내가 할 NorthWind database.I 사용이 AspxGridview.CategoryID에서 제품 테이블 정보를 원하는 제품 테이블에 배치의 열 중 하나입니다 보여주고 싶은 : 또한, 당신은이 오류에 대해 읽을 수 있습니다 해당 열에 형성 테이블에 Categories 테이블을 표시하려면 categories 테이블에서 CategoryName을 표시하고 싶습니다. 어떻게? < < GridViewDataComboBox 열을 만들어 이러한 데이터를 표시합니다.

http://documentation.devexpress.com/#AspNet/clsDevExpressWebASPxGridViewGridViewDataComboBoxColumntopic

:이 열 속성 설정에 두 개의 필드 사이에 링크를 당신을 허용