I have a radnumerictextbox in one column of a radgrid and a label in another column of the same radgrid.
I'm trying to calculate the value of the label when the radnumerictextbox changes. If I set up the event handler clientside it fires the event, but I don't know how to figure out what row in the radgrid to update the value in. If I try to set up the handler in the itemcreated event of the radgrid, it fires the function right away.( I assume this is because of the parenthesis). Here is the code snippets. Any ideas?
I'm trying to calculate the value of the label when the radnumerictextbox changes. If I set up the event handler clientside it fires the event, but I don't know how to figure out what row in the radgrid to update the value in. If I try to set up the handler in the itemcreated event of the radgrid, it fires the function right away.( I assume this is because of the parenthesis). Here is the code snippets. Any ideas?
<
telerik:RadGrid
runat
=
"server"
ID
=
"RewardProductsGrid"
EnableViewState
=
"True"
ShowStatusBar
=
"False"
ShowFooter
=
"False"
DataSourceID
=
"RewardProductsSource"
ShowHeader
=
"False"
OnItemDataBound
=
"RewardProductsGrid_OnItemDataBound"
OnItemCreated
=
"RewardProductsGrid_OnItemCreated"
>
<
ClientSettings
EnableAlternatingItems
=
"False"
></
ClientSettings
>
<
mastertableview
autogeneratecolumns
=
"False"
datakeynames
=
"ProductId"
editmode
=
"EditForms"
nomasterrecordstext
=
"No orders found."
allowsorting
=
"False"
allowmulticolumnsorting
=
"False"
>
<
Columns
>
<
telerik:GridTemplateColumn
AllowFiltering
=
"False"
>
<
ItemTemplate
>
<
asp:Image
runat
=
"server"
ImageUrl='<%# ((Product)Container.DataItem).CartImageUrl %>'/>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
AllowFiltering
=
"False"
>
<
ItemTemplate
>
<
asp:Label
runat
=
"server"
ID
=
"ProductNameLabel"
Text='<%# ((Product)Container.DataItem).NameLocalized %>'></
asp:Label
><
br
/>
<
asp:Label
runat
=
"server"
ID
=
"ItemNumberLabel"
></
asp:Label
>:#<
asp:Label
runat
=
"server"
ID
=
"ItemNumber"
Text='<%# ((Product)Container.DataItem).ProductNumber %>'></
asp:Label
>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
AllowFiltering
=
"False"
>
<
ItemTemplate
>
<
asp:Label
runat
=
"server"
ID
=
"PointsLabel"
></
asp:Label
>:<
br
/>
<
asp:Label
runat
=
"server"
ID
=
"Points"
Text='<%# String.Format("{0:#}",((Product)Container.DataItem).CurrentRewardPointPrice) %>'></
asp:Label
>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
AllowFiltering
=
"False"
>
<
ItemTemplate
>
<
asp:Label
runat
=
"server"
ID
=
"QuantityLabel"
></
asp:Label
>:<
br
/>
<
telerik:RadNumericTextBox
runat
=
"server"
ID
=
"QuantityTextBox"
Value
=
"1"
MaxValue
=
"10"
MinValue
=
"1"
>
<
NumberFormat
DecimalDigits
=
"0"
></
NumberFormat
>
<%-- <
ClientEvents
OnValueChanged
=
"QuantityTextBoxValueChanged"
></
ClientEvents
>--%>
</
telerik:RadNumericTextBox
>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
AllowFiltering
=
"False"
>
<
ItemTemplate
>
<
asp:Label
runat
=
"server"
ID
=
"ItemTotalLabel"
></
asp:Label
>:<
br
/>
<
asp:Label
runat
=
"server"
ID
=
"ItemTotal"
></
asp:Label
>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
</
Columns
>
</
mastertableview
>
</
telerik:RadGrid
>
protected void RewardProductsGrid_OnItemCreated(object sender, GridItemEventArgs e)
{
if (e.Item is GridDataItem)
{
GridDataItem item = (GridDataItem)e.Item;
RadNumericTextBox radNumericTextBox = (RadNumericTextBox)item.FindControl("QuantityTextBox");
// chkBox.Attributes.Add("onclick", "clicked_chkBox('" + item.ItemIndex + "')");
radNumericTextBox.ClientEvents.OnValueChanged = "change_quantity('" + item.ItemIndex + "')";
}
}
<
telerik:RadScriptBlock
ID
=
"RadGridScriptBlock"
runat
=
"server"
>
<
script
type
=
"text/javascript"
>
function CloseActiveToolTip() {
setTimeout(function () {
var tooltip = Telerik.Web.UI.RadToolTip.getCurrent();
if (tooltip) tooltip.hide();
}, 1000);
}
function refreshGrid() {
var masterTable = $find("<%= RewardProductsGrid.ClientID %>").get_masterTableView();
masterTable.rebind();
}
function QuantityTextBoxValueChanged(sender, args) {
alert("Test");
alert(sender.get_value());
}
function change_quantity(index) {
alert(index);
}
</
script
>
</
telerik:RadScriptBlock
>