Hi,
Please help.
I am getting this error:
Sys.WebForms.PageRequestManagerServerErrorException: There was a problem extracting DataKeyValues from the DataSource. Please ensure that DataKeyNames are specified correctly and all fields specified exist in the DataSource.
When I update the order item with OrderDetail_UpdateCommand and then gridCustomer.Rebind() and I get the error I mentioned above. Please help. Thanks.
Please help.
I am getting this error:
Sys.WebForms.PageRequestManagerServerErrorException: There was a problem extracting DataKeyValues from the DataSource. Please ensure that DataKeyNames are specified correctly and all fields specified exist in the DataSource.
When I update the order item with OrderDetail_UpdateCommand and then gridCustomer.Rebind() and I get the error I mentioned above. Please help. Thanks.
ASPX:
<telerik:RadGrid ID=
"gridCustomer"
runat=
"server"
OnNeedDataSource=
"gridCustomer_NeedDataSource"
OnUpdateCommand=
"OrderDetail_UpdateCommand"
OnDetailTableDataBind=
"gridOrder_DetailTableDataBind"
>
<MasterTableView DataKeyNames=
"CustomerID"
Width=
"100%"
PageSize=
"20"
ClientDataKeyNames=
"CustomerID"
>
<DetailTables>
<telerik:GridTableView DataKeyNames=
"OrderID"
Name=
"OrderDetail"
EditMode=
"InPlace"
>
<Columns>
<telerik:GridBoundColumn
DataField=
"OrderName"
HeaderText=
"Order Name"
ReadOnly=
"true"
/>
<telerik:GridBoundColumn
DataField=
"DateReceived"
HeaderText=
"Date Received"
ReadOnly=
"true"
/>
<telerik:GridTemplateColumn
HeaderText=
"Amount to Pay"
EditFormColumnIndex=
"1"
HeaderStyle-Width=
"140px"
>
<ItemTemplate>
<asp:Label runat=
"server"
ID=
"lblAmountToPay"
Text=
'<%# Eval ("AmountToPay", "{0:C}") %>'
> </asp:Label>
</ItemTemplate>
<EditItemTemplate>
<telerik:RadNumericTextBox runat=
"server"
ID=
"tbxUnitPrice"
Width=
"40px"
DbValue=
'<%# Bind("AmountToPay") %>'
>
</telerik:RadNumericTextBox>
</EditItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridEditCommandColumn UniqueName=
"EditOrderPrice"
/>
</Columns>
</telerik:GridTableView>
</DetailTables>
<Columns>
<telerik:GridClientSelectColumn UniqueName=
"ClientSelectColumn"
/>
<telerik:GridBoundColumn DataField=
"CustomerName"
HeaderText=
"Customer Name"
>
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField=
"Address"
HeaderText=
"Address"
>
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField=
"Phone"
HeaderText=
"Phone"
>
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField=
"Email"
HeaderText=
"Email"
>
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField=
"Group"
HeaderText=
"Group"
>
</telerik:GridBoundColumn>
</Columns>
</MasterTableView>
<ClientSettings>
<Selecting AllowRowSelect=
"True"
/>
<ClientEvents OnRowSelected=
"GridCustomerRowSelected"
/>
</ClientSettings>
</telerik:RadGrid>
CODE BEHIND
protected
void
gridCustomer_NeedDataSource(
object
source, GridNeedDataSourceEventArgs e) {
gridCustomer.DataSource = ClaimProcess.GetCustomer();
}
protected
void
gridOrder_DetailTableDataBind(
object
source, GridDetailTableDataBindEventArgs e) {
switch
(e.DetailTableView.Name)
{
case
"OrderDetail"
:
{
GridDataItem dataItem = e.DetailTableView.ParentItem;
e.DetailTableView.DataSource = ClaimProcess.GetOrder(dataItem.GetDataKeyValue(
"CustomerID"
));
break
;
}
}
}
protected
void
OrderDetail_UpdateCommand(
object
source, GridCommandEventArgs e)
{
GridEditableItem item = (GridEditableItem)e.Item;
int
OrderID = Convert.ToInt32(item.GetDataKeyValue(
"OrderID"
));
RadNumericTextBox txtAmountPay = (RadNumericTextBox)e.Item.FindControl(
"tbxUnitPrice"
);
UpdateOrder(OrderID, Convert.ToDouble(txtAmountPay.Text));
gridCustomer.Rebind();
}