2010-07-31 81 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在ASPxGridView - 展會信息指定的方法不支持

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; 
     } 

運行的代碼告訴我不支持錯誤消息指定的方法。

我使用羅斯文data​​base.I要顯示在AspxGridview.CategoryID產品表中的信息是產品table.I的列的一個要顯示該列中形成分類表,我想表明類別名稱來自類別表。 如何?

爲什麼顯示錯誤。如何解決這個問題。 點擊gridview的命令字段我想獲得基於CategoryName的CategoryID。

回答

1

顯示消息不支持指定的方法如果將LinqServerModeDataSource.EnableUpdate屬性設置爲true,則可以解決錯誤。此外,您還可以瞭解在此錯誤:

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

> 我使用羅斯文data​​base.I要顯示在AspxGridview.CategoryID產品表中的信息是產品table.I想要的列之一要在該列上顯示類別表格,我想從類別表中顯示類別名稱。如何? < < 創建GridViewDataComboBox列以顯示此類數據。這列屬性,可以設置兩個領域之間的聯繫:

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

相關問題