hi everybody
how can multuply 2 columns in a radgrid, i have to show the total in a 3 column(no footer) i have this code
For Each dataItem As GridDataItem In RadGrid1.Items
Dim txt1 As Integer = Val(dataItem("Template1").FindControl("txtunidades"))
Dim txt2 As Integer = Val(dataItem("Template2").FindControl("txtcunitario"))
dataItem("Template3").FindControl("txtvtotal") = txt1 * txt2
Next
how can multuply 2 columns in a radgrid, i have to show the total in a 3 column(no footer) i have this code
For Each dataItem As GridDataItem In RadGrid1.Items
Dim txt1 As Integer = Val(dataItem("Template1").FindControl("txtunidades"))
Dim txt2 As Integer = Val(dataItem("Template2").FindControl("txtcunitario"))
dataItem("Template3").FindControl("txtvtotal") = txt1 * txt2
Next
11 Answers, 1 is accepted
0

Robert
Top achievements
Rank 2
answered on 09 Jan 2012, 09:05 PM
i found this demo: http://demos.telerik.com/aspnet-ajax/grid/examples/generalfeatures/calculatedcolumns/defaultvb.aspx
my problem is that the user can edit price and units so i put 2 textbox i dont know why not working :( not update the total :(
<telerik:RadGrid AutoGenerateColumns="False" ID="RadGrid1" runat="server" DataSourceID="dsretaceo" >
<MasterTableView ShowFooter="true" DataKeyNames="COD_MATPRIMA"
DataSourceID="dsretaceo" >
<RowIndicatorColumn>
<HeaderStyle Width="20px"></HeaderStyle>
</RowIndicatorColumn>
<ExpandCollapseColumn>
<HeaderStyle Width="20px"></HeaderStyle>
</ExpandCollapseColumn>
<Columns>
<telerik:GridBoundColumn DataField="COD_MATPRIMA" HeaderText="COD_MATPRIMA"
ReadOnly="True" SortExpression="COD_MATPRIMA" UniqueName="COD_MATPRIMA">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="NOMMATPRI" HeaderText="NOMMATPRI"
SortExpression="NOMMATPRI" UniqueName="NOMMATPRI">
</telerik:GridBoundColumn>
<telerik:GridTemplateColumn UniqueName="Template1" DataField="unidades" DataType="System.Decimal"
HeaderText="UNIDADES" SortExpression="unidades">
<ItemTemplate>
<asp:TextBox ID="txtunidades" Type="number" runat="server" AutoPostBack="True" Text='<%#Eval("unidades") %>'></asp:TextBox>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn UniqueName="Template2" DataField="cunitario" DataType="System.Decimal"
HeaderText="VALOR UNITARIO" SortExpression="cunitario">
<ItemTemplate>
<asp:TextBox ID="txtcunitario" Type="number" runat="server" AutoPostBack="True" Text='<%#Eval("cunitario") %>'></asp:TextBox>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridCalculatedColumn HeaderText="Valor Total" UniqueName="TotalPrice" DataType="System.Double"
DataFields="unidades, cunitario" Expression="{0}*{1}" FooterText="Total : "
Aggregate="Sum" />
</Columns>
</MasterTableView>
</telerik:RadGrid>
my problem is that the user can edit price and units so i put 2 textbox i dont know why not working :( not update the total :(
<telerik:RadGrid AutoGenerateColumns="False" ID="RadGrid1" runat="server" DataSourceID="dsretaceo" >
<MasterTableView ShowFooter="true" DataKeyNames="COD_MATPRIMA"
DataSourceID="dsretaceo" >
<RowIndicatorColumn>
<HeaderStyle Width="20px"></HeaderStyle>
</RowIndicatorColumn>
<ExpandCollapseColumn>
<HeaderStyle Width="20px"></HeaderStyle>
</ExpandCollapseColumn>
<Columns>
<telerik:GridBoundColumn DataField="COD_MATPRIMA" HeaderText="COD_MATPRIMA"
ReadOnly="True" SortExpression="COD_MATPRIMA" UniqueName="COD_MATPRIMA">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="NOMMATPRI" HeaderText="NOMMATPRI"
SortExpression="NOMMATPRI" UniqueName="NOMMATPRI">
</telerik:GridBoundColumn>
<telerik:GridTemplateColumn UniqueName="Template1" DataField="unidades" DataType="System.Decimal"
HeaderText="UNIDADES" SortExpression="unidades">
<ItemTemplate>
<asp:TextBox ID="txtunidades" Type="number" runat="server" AutoPostBack="True" Text='<%#Eval("unidades") %>'></asp:TextBox>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn UniqueName="Template2" DataField="cunitario" DataType="System.Decimal"
HeaderText="VALOR UNITARIO" SortExpression="cunitario">
<ItemTemplate>
<asp:TextBox ID="txtcunitario" Type="number" runat="server" AutoPostBack="True" Text='<%#Eval("cunitario") %>'></asp:TextBox>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridCalculatedColumn HeaderText="Valor Total" UniqueName="TotalPrice" DataType="System.Double"
DataFields="unidades, cunitario" Expression="{0}*{1}" FooterText="Total : "
Aggregate="Sum" />
</Columns>
</MasterTableView>
</telerik:RadGrid>
0

Robert
Top achievements
Rank 2
answered on 10 Jan 2012, 05:43 PM
anybody help me plz? :(
0
Hi,
I followed your scenario and prepared a simple working project which handles the desired functionality. Give it a try and let me know if it helps to achieve your goal.
Kind regards,
Pavlina
the Telerik team
I followed your scenario and prepared a simple working project which handles the desired functionality. Give it a try and let me know if it helps to achieve your goal.
Kind regards,
Pavlina
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0

Robert
Top achievements
Rank 2
answered on 10 Jan 2012, 09:10 PM
thanks for ur help Pavlina
i had problems with ur code, sorry i am very new in this, i cant open all the files i had to look one by one but i couldnt :(.. i am trying with this code :
Dim Connstring As String = " "
Dim Conn As SqlConnection = New SqlConnection(Connstring)
Dim t As DataTable = New DataTable()
Dim dacompletar As New SqlDataAdapter("SELECT TBL_MATERIAPRIMA.COD_MATPRIMA, TBL_MATERIAPRIMA.NOMMATPRI FROM TBL_MATERIAP_PROVEEDOR INNER JOIN TBL_MATERIAPRIMA ON TBL_MATERIAP_PROVEEDOR.COD_MATPRIMA = TBL_MATERIAPRIMA.COD_MATPRIMA INNER JOIN TBL_PROVEEDOR ON TBL_MATERIAP_PROVEEDOR.COD_PROVEE = TBL_PROVEEDOR.COD_PROVEE", Conn)
dacompletar.Fill(t)
t.Columns.Add("Cantidad", System.Type.GetType("System.Decimal"))
t.Columns.Add("Precio", System.Type.GetType("System.Decimal"))
Dim c As DataColumn = t.Columns.Add("Total", System.Type.GetType("System.Decimal"))
c.Expression = "[Cantidad] * [Precio]"
Me.RadGrid1.DataSource = t
Me.RadGrid1.DataBind()
so my problem right now is how to adding the value of c to my textbox in my radgrid
Dim Connstring As String = " "
Dim Conn As SqlConnection = New SqlConnection(Connstring)
Dim t As DataTable = New DataTable()
Dim dacompletar As New SqlDataAdapter("SELECT TBL_MATERIAPRIMA.COD_MATPRIMA, TBL_MATERIAPRIMA.NOMMATPRI FROM TBL_MATERIAP_PROVEEDOR INNER JOIN TBL_MATERIAPRIMA ON TBL_MATERIAP_PROVEEDOR.COD_MATPRIMA = TBL_MATERIAPRIMA.COD_MATPRIMA INNER JOIN TBL_PROVEEDOR ON TBL_MATERIAP_PROVEEDOR.COD_PROVEE = TBL_PROVEEDOR.COD_PROVEE", Conn)
dacompletar.Fill(t)
t.Columns.Add("Cantidad", System.Type.GetType("System.Decimal"))
t.Columns.Add("Precio", System.Type.GetType("System.Decimal"))
Dim c As DataColumn = t.Columns.Add("Total", System.Type.GetType("System.Decimal"))
c.Expression = "[Cantidad] * [Precio]"
Me.RadGrid1.DataSource = t
Me.RadGrid1.DataBind()
so my problem right now is how to adding the value of c to my textbox in my radgrid
0

Robert
Top achievements
Rank 2
answered on 11 Jan 2012, 05:58 AM
i will try to explain what i want to do, i have a radgrid where retrieve two field of my database, a code and a product name, so the user have to put the price and units of the products (these are 2 field that no retrieve of database, are empty field in the grid that i have to edit), next i have to get total price (price* units) :(
0
Hi,
I moved the code from the project which I sent you in the previous post in a simple website. Can you please give it a try and let me know if you have any problems with it?
Regards,
Pavlina
the Telerik team
I moved the code from the project which I sent you in the previous post in a simple website. Can you please give it a try and let me know if you have any problems with it?
Regards,
Pavlina
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0

Robert
Top achievements
Rank 2
answered on 11 Jan 2012, 03:53 PM
hi Pavlina
i put ur code in my project and i can see i had these error in the code: NeedDataSource(source As Objesct, e AS Telerik.Web.Ui.GridNeedDataSourceEvent Args)' is an event and cannot be called directly. Use a 'RaiseEvent' statement to raise an event
Delegate 'Telerik.Web.Ui.GridNeedDtaSourceEventHandler' requerires an 'AdreessOf' or lambda expression as the only argument to its constructor.
Protected Overrides Sub OnInit(ByVal e As EventArgs)
MyBase.OnInit(e)
RadGrid1.NeedDataSource += New GridNeedDataSourceEventHandler(RadGrid1_NeedDataSource)
End Sub
well i run the project and the total is show correctly but if i change the value in the textbox not change the result i imagine that is for the error that i mention u :( could u help me and sorry :( for all my simple questions i am very new in this its my first time that i am programming in .net and using teleriks control
i found this: AddHandler RadGrid1.NeedDataSource, AddressOf RadGrid1_NeedDataSource but isnt work yet :(
Delegate 'Telerik.Web.Ui.GridNeedDtaSourceEventHandler' requerires an 'AdreessOf' or lambda expression as the only argument to its constructor.
Protected Overrides Sub OnInit(ByVal e As EventArgs)
MyBase.OnInit(e)
RadGrid1.NeedDataSource += New GridNeedDataSourceEventHandler(RadGrid1_NeedDataSource)
End Sub
well i run the project and the total is show correctly but if i change the value in the textbox not change the result i imagine that is for the error that i mention u :( could u help me and sorry :( for all my simple questions i am very new in this its my first time that i am programming in .net and using teleriks control
i found this: AddHandler RadGrid1.NeedDataSource, AddressOf RadGrid1_NeedDataSource but isnt work yet :(
0

Robert
Top achievements
Rank 2
answered on 12 Jan 2012, 03:21 PM
What i have to do for refresh the radgrid when i edit the values of my textbox :(
0

Robert
Top achievements
Rank 2
answered on 13 Jan 2012, 03:20 PM
the problem is that i only have to refresh the datagrid because i dont retrieve field of my data base after modify i have to save but is not problem
0
Hello,
To achieve the desired functionality you can use similar to this example approach:
http://demos.telerik.com/aspnet-ajax/controls/examples/integration/gridandinput/defaultcs.aspx?product=grid
Greetings,
Pavlina
the Telerik team
To achieve the desired functionality you can use similar to this example approach:
http://demos.telerik.com/aspnet-ajax/controls/examples/integration/gridandinput/defaultcs.aspx?product=grid
Greetings,
Pavlina
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0

Robert
Top achievements
Rank 2
answered on 20 Jan 2012, 12:30 AM
Thank for ur help Plavlina :)