AspxGridView Specified method is not supported. problem
Posted
by
shamim
on Stack Overflow
See other posts from Stack Overflow
or by shamim
Published on 2010-07-12T16:43:26Z
Indexed on
2012/09/24
15:37 UTC
Read the original article
Hit count: 372
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.
© Stack Overflow or respective owner