views:

87

answers:

3

Bellow is my .aspx aspxGridview syntax

 <dx:ASPxGridView ID="ASPxGridView1" runat="server" AutoGenerateColumns="False" 
            KeyFieldName="intProductCode" onrowinserted="ASPxGridView1_RowInserted">
            <Columns>
                <dx:GridViewCommandColumn VisibleIndex="0">
                    <EditButton Visible="True">
                    </EditButton>
                    <NewButton Visible="True">
                    </NewButton>
                    <DeleteButton Visible="True">
                    </DeleteButton>
                </dx:GridViewCommandColumn>
                <dx:GridViewDataTextColumn Caption="intProductCode" FieldName="intProductCode" 
                    VisibleIndex="1">
                </dx:GridViewDataTextColumn>
                <dx:GridViewDataTextColumn Caption="strProductName" FieldName="strProductName" 
                    VisibleIndex="2">
                </dx:GridViewDataTextColumn>
                <dx:GridViewDataTextColumn Caption="SKU" FieldName="SKU" VisibleIndex="3">
                </dx:GridViewDataTextColumn>
                <dx:GridViewDataTextColumn Caption="PACK" FieldName="PACK" VisibleIndex="4">
                </dx:GridViewDataTextColumn>
                <dx:GridViewDataTextColumn Caption="intQtyPerCase" FieldName="intQtyPerCase" 
                    VisibleIndex="5">
                </dx:GridViewDataTextColumn>
                <dx:GridViewDataTextColumn Caption="mnyCasePrice" FieldName="mnyCasePrice" 
                    VisibleIndex="6">
                </dx:GridViewDataTextColumn>
                <dx:GridViewDataTextColumn Caption="intTBQtyPerCase" 
                    FieldName="intTBQtyPerCase" VisibleIndex="7">
                </dx:GridViewDataTextColumn>
                <dx:GridViewDataCheckColumn Caption="bIsActive" FieldName="bIsActive" 
                    VisibleIndex="8">
                </dx:GridViewDataCheckColumn>
                <dx:GridViewDataTextColumn Caption="intSortingOrder" 
                    FieldName="intSortingOrder" VisibleIndex="9">
                </dx:GridViewDataTextColumn>
                <dx:GridViewDataTextColumn Caption="strProductAccCode" 
                    FieldName="strProductAccCode" VisibleIndex="10">
                </dx:GridViewDataTextColumn>
            </Columns>
        </dx:ASPxGridView>

Bellow is my C# syntax :

 protected void Page_Load(object sender, EventArgs e)
        {
            if (this.IsPostBack != true)
            {
                BindGridView();
            }
        }

        private void BindGridView()
        {
            DB_OrderV2DataContext db = new DB_OrderV2DataContext();
            var r = from p in db.tblProductInfos
                    select p;
            ASPxGridView1.DataSource = r;
            ASPxGridView1.DataBind();
        }

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


        }

        protected void ASPxGridView1_RowInserted(object sender, DevExpress.Web.Data.ASPxDataInsertedEventArgs e)
        {
            DB_OrderV2DataContext db = new DB_OrderV2DataContext();


            tblProductInfo otblProductInfo = new tblProductInfo ();

            otblProductInfo.intProductCode = (db.tblProductInfos.Max(p => (int?)p.intProductCode) ?? 0) + 1;//oProductController.GenerateProductCode();
            otblProductInfo.strProductName = Convert.ToString(e.NewValues["strProductName"]);
            otblProductInfo.SKU = Convert.ToString(e.NewValues["SKU"]);
            otblProductInfo.PACK = Convert.ToString(e.NewValues["PACK"]);
            otblProductInfo.intQtyPerCase = Convert.ToInt32(e.NewValues["intQtyPerCase"]);
            otblProductInfo.mnyCasePrice = Convert.ToDecimal(e.NewValues["mnyCasePrice"]);
            otblProductInfo.intTBQtyPerCase = Convert.ToInt32(e.NewValues["intTBQtyPerCase"]);
            otblProductInfo.bIsActive = Convert.ToBoolean(e.NewValues["bIsActive"]);
            otblProductInfo.intSortingOrder = (db.tblProductInfos.Max(p => (int?)p.intSortingOrder) ?? 0) + 1;//oProductController.GenerateSortingOrder();

            db.tblProductInfos.InsertOnSubmit(otblProductInfo);//the InsertOnSubmit method called in the preceding code was named Add and the DeleteOnSubmit method was named Remove.
            db.SubmitChanges();
            BindGridView();
            //oProductController.InsertAndSubmit();
           // ASPxGridView1.DataBind();
        }

My SQL syntax

CREATE TABLE [dbo].[tblProductInfo](
    [intProductCode] [int] NOT NULL,
    [strProductName] [varchar](100) NULL,
    [SKU] [varchar](50) NULL,
    [PACK] [varchar](50) NULL,
    [intQtyPerCase] [int] NULL,
    [mnyCasePrice] [money] NULL,
    [intTBQtyPerCase] [int] NULL,
    [bIsActive] [bit] NULL,
    [intSortingOrder] [int] NULL,
    [strProductAccCode] [varchar](max) NULL,
 CONSTRAINT [PK_tblProductInfo] PRIMARY KEY CLUSTERED 
(
    [intProductCode] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

When i want to insert ,show me error message Specified method is not supported. How to solve it.

A: 

hi you just ensure you want to insert or update.In your Inserting method need to write e.cancle=true

http://community.devexpress.com/forums/p/74138/253467.aspx

shamim
A: 

Hi,

The "Specified Method is Not Supported" error message is shown when the ASPxGridView tries to call the Update (Insert, Delete) command of its underlying DataSource, but this command is not specified. If you cannot define this command, handle the RowUpdating (RowInserting, RowDeleting) event, update the data source manually (the e.NewValues dictionary contains input value) and finally, set the e.Cancel parameter to true and call the ASPxGridView.CancelEdit method.

DevExpress Team
will you please send some syntax.I want to insert than update,than delete.If i set e.Cancle=true on rowInserting method then rowInserted method not work.
shamim
Indeed, the E257 example shows how these events can be used. Why do you need to use the RowInserted event? In your case, it should not be raised and all the code should be implemented within the RowInserting event handler.
DevExpress Team
A: 

this contain the solution what to do .How to do

http://www.devexpress.com/Support/Center/e/E257.aspx

shamim