I've created a grid where the last column is defined thusly:
<telerik:GridTemplateColumn UniqueName="StdHrs" DataField="StdHrs">
<HeaderTemplate>Std Hrs</HeaderTemplate>
<ItemTemplate>
<asp:Label ID="labelStdHrs" runat="server" Width="100%" Text='<%# Bind("StdHrs") %>' />
</ItemTemplate>
</telerik:GridTemplateColumn>
The Std Hrs on each row = Quantity x Rate
After a little research I determined this approach to update the Std Hrs value when a number is changed in the Quantity (aka Units) TextBox:
float stdHrs = Tools.Round((float)dataRows[0]["Rate"] * newval, 2);
dataRows[0]["StdHrs"] = stdHrs;
GridDataItem item = (GridDataItem)textBox.NamingContainer;
Label label = (Label)item.FindControl("labelStdHrs");
label.Text = stdHrs.ToString();
This does work but it seems rather redundant to have to update both the underlying DataTable (that the Grid is bound to) as well as the Label that sits in the row.
Is there, in fact, a more efficient way to do this?
Robert
<telerik:GridTemplateColumn UniqueName="StdHrs" DataField="StdHrs">
<HeaderTemplate>Std Hrs</HeaderTemplate>
<ItemTemplate>
<asp:Label ID="labelStdHrs" runat="server" Width="100%" Text='<%# Bind("StdHrs") %>' />
</ItemTemplate>
</telerik:GridTemplateColumn>
The Std Hrs on each row = Quantity x Rate
After a little research I determined this approach to update the Std Hrs value when a number is changed in the Quantity (aka Units) TextBox:
float stdHrs = Tools.Round((float)dataRows[0]["Rate"] * newval, 2);
dataRows[0]["StdHrs"] = stdHrs;
GridDataItem item = (GridDataItem)textBox.NamingContainer;
Label label = (Label)item.FindControl("labelStdHrs");
label.Text = stdHrs.ToString();
This does work but it seems rather redundant to have to update both the underlying DataTable (that the Grid is bound to) as well as the Label that sits in the row.
Is there, in fact, a more efficient way to do this?
Robert