if either of them is changed the back end database is updated
I used a template with a label in the ItemTemplate and a RadNumericTextBox in the EditItemTemplate and triggered the update on the quantity changed event for the quantity
but... then the automatic aggregate didn't work - and there is a lot of filtering possible
my kluge is to have 2 quantity columns - one read only for the total and the other a template with only the EditItemTemplate
is there a way to update the quantity with only one column and still aggregate without a lot of extra code?
7 Answers, 1 is accepted
Can you, please show us some sample code demonstrating the approach you have taken? What do you mean by "then the automatic aggregate didn't work", are your data values updated but the aggregates don't, or your data values are not updated at all (indicating data update is unsuccessful). Also, can you, please, show us how do you update the grid when the quantity changes in the textbox?
Greetings,
Veli
the Telerik team
Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

the EditItemTemplate has a RADNumericTextBox and the update is done on the Changed event
<
telerik:RadGrid
ID
=
"rgEditOrder"
OnNeedDataSource
=
"rgEditOrder_NeedDataSource"
OnItemCommand
=
"rgEditOrder_ItemCommand"
OnItemCreated
=
"rgEditOrder_ItemCreated"
ShowFooter
=
"True"
runat
=
"server"
>
<
GroupingSettings
CaseSensitive
=
"false"
/>
<
MasterTableView
DataKeyNames
=
"OrderSeq"
AutoGenerateColumns
=
"false"
AllowSorting
=
"true"
AllowPaging
=
"true"
AllowFilteringByColumn
=
"False"
EditMode
=
"InPlace"
>
<
Columns
>
<
telerik:GridBoundColumn
UniqueName
=
"StoreNumber"
DataField
=
"StoreNumber"
HeaderText
=
"Store #"
DataFormatString
=
"{0:#####}"
DataType
=
"System.Int32"
Aggregate
=
"None"
ReadOnly
=
"True"
>
<
HeaderStyle
Width
=
"40px"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
UniqueName
=
"BoothNumber"
DataField
=
"BoothNumber"
HeaderText
=
"Booth #"
DataFormatString
=
"{0:#####}"
DataType
=
"System.Int32"
Aggregate
=
"None"
ReadOnly
=
"True"
>
<
HeaderStyle
Width
=
"40px"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
UniqueName
=
"ItemID"
DataField
=
"ItemID"
HeaderText
=
"Item"
DataType
=
"System.Double"
Aggregate
=
"None"
ReadOnly
=
"True"
>
<
HeaderStyle
Width
=
"40px"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
UniqueName
=
"ItemDescription"
DataField
=
"ItemDescription"
HeaderText
=
"Description"
ReadOnly
=
"True"
>
<
HeaderStyle
Width
=
"100px"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridDateTimeColumn
UniqueName
=
"ShipDate"
DataField
=
"ShipDate"
PickerType
=
"DatePicker"
HeaderText
=
"Ship Date"
DataFormatString
=
"{0:d}"
DataType
=
"System.DateTime"
>
<
HeaderStyle
Width
=
"60px"
/>
</
telerik:GridDateTimeColumn
>
<
telerik:GridTemplateColumn
UniqueName
=
"Cases"
HeaderText
=
""
>
<
EditItemTemplate
>
<
telerik:RadNumericTextBox
ID
=
"rntbQty"
Text='<%# Eval("Qty") %>' MinValue='<%# Bind("Qty") %>' OnTextChanged="rntbQty_TextChanged" AutoPostBack="True" Width="30px" runat="server">
<
NumberFormat
DecimalDigits
=
"0"
/>
</
telerik:RadNumericTextBox
>
</
EditItemTemplate
>
<
HeaderStyle
Width
=
"30px"
/>
</
telerik:GridTemplateColumn
>
<
telerik:GridBoundColumn
UniqueName
=
"Qty"
DataField
=
"Qty"
HeaderText
=
"Cases"
DataFormatString
=
"{0:#####}"
DataType
=
"System.Int32"
Aggregate
=
"Sum"
ReadOnly
=
"True"
>
<
HeaderStyle
Width
=
"30px"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
UniqueName
=
"NetCost"
DataField
=
"NetCost"
HeaderText
=
"Net Cost"
DataFormatString
=
"{0:C2}"
DataType
=
"System.Double"
Aggregate
=
"None"
ReadOnly
=
"True"
>
<
HeaderStyle
Width
=
"50px"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
UniqueName
=
"ItemTotal"
DataField
=
"ItemTotal"
HeaderText
=
"Item Total"
DataFormatString
=
"{0:C2}"
DataType
=
"System.Double"
Aggregate
=
"Sum"
ReadOnly
=
"True"
>
<
HeaderStyle
Width
=
"50px"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
UniqueName
=
"PageNumber"
DataField
=
"PageNumber"
HeaderText
=
"Page"
DataFormatString
=
"{0:#####}"
DataType
=
"System.Int32"
Aggregate
=
"None"
ReadOnly
=
"True"
>
<
HeaderStyle
Width
=
"40px"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
UniqueName
=
"VendorNumber"
DataField
=
"VendorNumber"
HeaderText
=
"Vendor"
DataFormatString
=
"{0:#####}"
DataType
=
"System.Int32"
Aggregate
=
"None"
ReadOnly
=
"True"
>
<
HeaderStyle
Width
=
"40px"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
UniqueName
=
"DepartmentNumber"
DataField
=
"DepartmentNumber"
HeaderText
=
"Depart"
DataFormatString
=
"{0:##}"
DataType
=
"System.Int32"
Aggregate
=
"None"
ReadOnly
=
"True"
>
<
HeaderStyle
Width
=
"30px"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
UniqueName
=
"OrderSeq"
DataField
=
"OrderSeq"
DataType
=
"System.Int64"
Visible
=
"false"
>
</
telerik:GridBoundColumn
>
</
Columns
>
</
MasterTableView
>
<
ClientSettings
>
<
ClientEvents
OnRowDblClick
=
"RowDblClick"
/>
<
ClientEvents
OnRowClick
=
"RowClick"
/>
</
ClientSettings
>
</
telerik:RadGrid
>
these go in a RADCodeBlock
function
RowDblClick(sender, eventArgs) {
idx = eventArgs.get_itemIndexHierarchical();
sender.get_masterTableView().editItem(idx);
}
function
RowClick(sender, eventArgs) {
idx = eventArgs.get_itemIndexHierarchical();
sender.get_masterTableView().editItem(idx);
}
protected
void
rgEditOrder_NeedDataSource(
object
source, GridNeedDataSourceEventArgs e)
{
DataSet dsOrder =
new
DataSet();
if
(txtStoreHidden.Value ==
""
)
{
return
;
}
WsOrderSystem wsOrder =
new
WsOrderSystem();
dsOrder = wsOrder.GetOnlineOrder(Convert.ToDouble(txtStoreHidden.Value), txtChain.Value);
rgEditOrder.DataSource = dsOrder;
Session[
"EditOrderView"
] = dsOrder;
}
protected
void
rntbQty_TextChanged(
object
sender, EventArgs e)
{
RadNumericTextBox rntbQty;
GridDataItem gdItem;
GridEditableItem geItem;
DateTime ShipDate;
int
Qty,iBooth,iPage,iConsolid;
double
fStore,dVendor,dItemID,dNetCost;
string
[] strDel =
new
string
[1];
double
[] dQty =
new
double
[1];
Hashtable CornedBeef;
WsOrderSystem wsOrder;
bool
bUpdate =
false
;
rntbQty = (RadNumericTextBox)sender;
gdItem = rntbQty.NamingContainer
as
GridDataItem;
geItem = rntbQty.NamingContainer
as
GridEditableItem;
CornedBeef =
new
Hashtable();
gdItem.ExtractValues(CornedBeef);
ShipDate = Convert.ToDateTime(CornedBeef[
"ShipDate"
]);
Qty = Convert.ToInt32(rntbQty.Value);
fStore = Convert.ToDouble(ExtractValue(geItem,
"StoreNumber"
));
iBooth = Convert.ToInt32(ExtractValue(geItem,
"BoothNumber"
));
iPage = Convert.ToInt32(ExtractValue(geItem,
"PageNumber"
));
dVendor = Convert.ToDouble(ExtractValue(geItem,
"VendorNumber"
));
dNetCost = Convert.ToDouble(ExtractValue(geItem,
"NetCost"
));
dItemID = Convert.ToDouble(ExtractValue(geItem,
"ItemID"
));
iConsolid = Convert.ToInt32(txtConsolid.Value);
strDel[0] = ShipDate.ToShortDateString();
dQty[0] = Qty;
wsOrder =
new
WsOrderSystem();
bUpdate = wsOrder.AddToOrder(fStore,iBooth,iPage,dVendor,dNetCost,dItemID,strDel,dQty,
true
,iConsolid);
}
protected
void
rdpShipDate_SelectedDateChanged(
object
sender, EventArgs e)
{
RadDatePicker rdpShipDate;
GridEditableItem geItem;
DateTime OldShipDate,NewShipDate;
double
fStore,dItemID;
int
iBooth,iPage;
string
strOldDel,strNewDel;
bool
bUpdate=
false
;
WsOrderSystem wsOrder;
rdpShipDate = (sender
as
RadDatePicker);
geItem = rdpShipDate.NamingContainer
as
GridEditableItem;
NewShipDate = Convert.ToDateTime(rdpShipDate.SelectedDate);
OldShipDate = Convert.ToDateTime((e
as
Telerik.Web.UI.Calendar.SelectedDateChangedEventArgs).OldDate);
fStore = Convert.ToDouble(ExtractValue(geItem,
"StoreNumber"
));
iBooth = Convert.ToInt32(ExtractValue(geItem,
"BoothNumber"
));
dItemID = Convert.ToDouble(ExtractValue(geItem,
"ItemID"
));
iPage = Convert.ToInt32(ExtractValue(geItem,
"PageNumber"
));
strOldDel = OldShipDate.ToShortDateString();
strNewDel = NewShipDate.ToShortDateString();
wsOrder =
new
WsOrderSystem();
bUpdate = wsOrder.UpdateOrder(fStore,iBooth,iPage,dItemID,strOldDel,strNewDel);
}
private
string
ExtractValue(GridEditableItem geItem,
string
UniqueName)
{
TableCell tCell;
string
strValue;
tCell = geItem[UniqueName];
strValue = (tCell.Controls[0]
as
TextBox).Text;
strValue = strValue.Replace(
"$"
,
""
);
return
strValue;
}
I pasted the relevant code - but some of the page controls I left out

<
telerik:GridTemplateColumn
UniqueName
=
"Cases"
HeaderText
=
""
>
<
EditItemTemplate
>
<
telerik:RadNumericTextBox
ID
=
"rntbQty"
Text='<%# Eval("Qty") %>' MinValue='<%# Bind("Qty") %>' OnTextChanged="rntbQty_TextChanged" AutoPostBack="True" Width="30px" runat="server">
<
NumberFormat
DecimalDigits
=
"0"
/>
</
telerik:RadNumericTextBox
>
</
EditItemTemplate
>
<
HeaderStyle
Width
=
"30px"
/>
</
telerik:GridTemplateColumn
>
<
telerik:GridBoundColumn
UniqueName
=
"Qty"
DataField
=
"Qty"
HeaderText
=
"Cases"
DataFormatString
=
"{0:#####}"
DataType
=
"System.Int32"
Aggregate
=
"Sum"
ReadOnly
=
"True"
>
<
HeaderStyle
Width
=
"30px"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridTemplateColumn
UniqueName
=
"Qty"
HeaderText
=
"Cases"
Aggregate
=
"Sum"
>
<
ItemTemplate
>
<
asp:Label
ID
=
"lblQty"
Text='<%# Bind("Qty") %>' Width="40px" runat="server" />
</
ItemTemplate
>
<
EditItemTemplate
>
<
telerik:RadNumericTextBox
ID
=
"rntbQty"
Text='<%# Eval("Qty") %>' MinValue='<%# Bind("Qty") %>' OnTextChanged="rntbQty_TextChanged" AutoPostBack="True" Width="40px" runat="server">
<
NumberFormat
DecimalDigits
=
"0"
/>
</
telerik:RadNumericTextBox
>
</
EditItemTemplate
>
<
HeaderStyle
Width
=
"40px"
/>
</
telerik:GridTemplateColumn
>
the page throws an exception
In the "Qty" column, you should use Eval, to evaluate the value of Qty field to the MinValue of the rntbQty NumericTextBox.
In the ItemTemplate you should use Eval instead of Bind for populating the Label.
Also you should Bind to the DbValue property instead of the text property if the type in you database is numeric.
Try the declaration below and if the problem still exist please let me know what exactly is the exception.
<
telerik:GridTemplateColumn
UniqueName
=
"Qty"
HeaderText
=
"Cases"
Aggregate
=
"Sum"
>
<
ItemTemplate
>
<
asp:Label
ID
=
"lblQty"
Text='<%# Eval("Qty") %>' Width="40px" runat="server" />
</
ItemTemplate
>
<
EditItemTemplate
>
<
telerik:RadNumericTextBox
ID
=
"rntbQty"
DbValue='<%# Bind("Qty") %>' MinValue='<%# Eval("Qty") %>'
OnTextChanged="rntbQty_TextChanged" AutoPostBack="True" Width="40px" runat="server">
<
NumberFormat
DecimalDigits
=
"0"
/>
</
telerik:RadNumericTextBox
>
</
EditItemTemplate
>
<
HeaderStyle
Width
=
"40px"
/>
</
telerik:GridTemplateColumn
>
All the best,
Vasil
the Telerik team
Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

getting exception - doesn't like the aggregate
Server Error in '/WebPages' Application.
The expression contains invalid name: '[])'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SyntaxErrorException: The expression contains invalid name: '[])'.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. |
Stack Trace:
|
Version Information: Microsoft .NET Framework Version:2.0.50727.3620; ASP.NET Version:2.0.50727.3618
Set DataField and DataType properties inside the decalration of the column. This should work:
DataField="Qty" DataType="System.Int32"
Best wishes,
Vasil
the Telerik team
Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

thanks