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.
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.
If you do not plan on using the DataSource commands then you can use the Grid RowUpdating event and set e.Cancel = true then call grid.CancelEdit() method (As mentioned by DevExpress Team above. Below is an example:
void grid_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e)
{
// Your update logic here.
e.Cancel = true;
this.editableGrid.CancelEdit();
}
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
this contain the solution what to do .How to do
http://www.devexpress.com/Support/Center/e/E257.aspx
精彩评论