ASPxGridView 中的 DropDownLists - 显示消息不支持指定的方法

发布于 2024-09-12 06:23:56 字数 4928 浏览 1 评论 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#语法:

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

运行代码显示错误消息不支持指定的方法。

我使用NorthWind数据库。我想在AspxGridview中显示Product表信息。CategoryID是其中之一产品表的列。我想在该列上显示类别表的信息,我想显示类别表中的类别名称如何? >

为什么显示错误。如何解决此问题。 单击gridview的命令字段,我想根据CategoryName获取CategoryID。

<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# 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

℉服软 2024-09-19 06:23:56

如果将 LinqServerModeDataSource.EnableUpdate 属性设置为 true,则可以解决显示消息不支持指定的方法错误。另外,您可以在以下位置阅读有关此错误的信息:

>
我使用 NorthWind 数据库。我想在 AspxGridview 中显示产品表信息。CategoryID 是产品表的列之一。我想在该列上显示类别表的信息,我想显示类别表中的类别名称。如何操作?
<<
创建 GridViewDataComboBox 列来显示此类数据。此列属性允许您设置两个字段之间的链接:

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

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文