开发者

DropDownLists in ASPxGridView - Show message Specified method is not supported

<div>

    <dx:ASPxGridView ID="ASPxGridView1" runat="server" AutoGenerateColumns="False" 
        ClientInstanceName="ASPxGridView1" DataSourceID="LinqServerModeDataSource1" 
        KeyFieldName="ProductID" 
        oncelleditorinitia开发者_C百科lize="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# syntax:

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

Run the code show me the error message Specified method is not supported.

I use NorthWind database.I want to show Product table information in AspxGridview.CategoryID is one of the column of Product table.I want to show Categories table in formation on that column,I want to show CategoryName from categories table.How to ?

Why showing the error.How to solve this problem. Click on command field of gridview i want to get CategoryID on basis of CategoryName.


The Show message Specified method is not supported error can be resolved if you set the LinqServerModeDataSource.EnableUpdate property to true. Also, you can read about this error at:

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

> I use NorthWind database.I want to show Product table information in AspxGridview.CategoryID is one of the column of Product table.I want to show Categories table in formation on that column,I want to show CategoryName from categories table.How to ? << Create the GridViewDataComboBox column to show such data. This column properties allow you to setup a link between two fields:

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜