I would like to calculate in specific items. In my current case, if you write in the first txtstake calculated in all items.
I think that I need to use [i] in jquery? But how?
Please check my code.
Jquery:
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$("input[type=text][id*=txtStake]").keyup(function () {
var sum1 = $("[id*=lblStake]").html();
var sum2 = $("input[type=text][id*=txtStake]").val();
var test = sum1 * sum2;
$("[id*=lblStake]").html(test.toFixed(2));
});
});
</script>
How to opened this project? Because returns error:
Parser Error
Description:
An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: Could not load type 'WebAppSampleGridview.Default'.
Source Error:
Line 1: <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebAppSampleGridview.Default" %> Line 2:
Line 3: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
programercek
Participant
1510 Points
2244 Posts
jquery datalist
Apr 18, 2012 08:40 AM|LINK
Hello,
I would like to calculate in specific items. In my current case, if you write in the first txtstake calculated in all items.
I think that I need to use [i] in jquery? But how?
Please check my code.
Jquery:
<script src="http://code.jquery.com/jquery-latest.js"></script> <script type="text/javascript"> $(document).ready(function () { $("input[type=text][id*=txtStake]").keyup(function () { var sum1 = $("[id*=lblStake]").html(); var sum2 = $("input[type=text][id*=txtStake]").val(); var test = sum1 * sum2; $("[id*=lblStake]").html(test.toFixed(2)); }); }); </script>DataList:
<asp:DataList ID="DataList1" runat="server" Width="238px" > <ItemTemplate> <div class="slipbet-data"> <div style="float:left; margin-left:-4px; margin-top:2px;"><asp:Image ID="Image1" runat="server" ImageUrl="~/images/datetime-icon.png" ImageAlign="AbsBottom" ToolTip='<%# Eval("DateOfEvent") %>' /></div><div style="margin-left:15px;"><asp:Label ID="lblNameOfEventLabel" runat="server" Text='<%# Eval("NameOfEvent") %>'></asp:Label></div> <div style="margin-left:15px;"><asp:Label ID="lblTypeOfBets" runat="server" Text='<%# Eval("TypeOfBets") %>'></asp:Label></div> <div style="float:left; margin-left:15px;"><asp:Label ID="lblPickLabel" runat="server" Font-Bold="true" Text="Pick:"> </asp:Label> <asp:Label ID="lblPick" runat="server" Font-Bold="true" Text='<%# Eval("Pick") %>'></asp:Label></div> <div style="float:right"><asp:Label ID="lblOddsLabel" runat="server" Text='<%# Eval("Odds") %>'></asp:Label></div><br /> <%--<div style="margin-left:15px;">Stake <asp:TextBox ID="txtStake" Text='<%# Eval("Stake") %>' runat="server" Height="12px" Width="50px"></asp:TextBox></div>--%> <div style="margin-left:15px;">Stake <asp:TextBox ID="txtStake" Text=<%# (Convert.ToString(Eval("Stake"))) == "" ? "0.00" : Eval("Stake") %> runat="server" Height="12px" Width="50px"></asp:TextBox></div> <asp:Label ID="lblStake" runat="server" Text="10"></asp:Label> </div> </ItemTemplate>Please help me.
abiruban
All-Star
16048 Points
2734 Posts
Re: jquery datalist
Apr 18, 2012 11:52 AM|LINK
Hi,
This article elaborates how to interact javascript with web service to populate GridView, you just need to change the GridView to DataList control:
http://www.codeproject.com/Articles/106104/NET-Gridview-with-AJAX-and-REST-Web-Services
***DON'T FORGET TO CLICK “MARK AS ANSWER” ON THE POST IF HELPED YOU.
programercek
Participant
1510 Points
2244 Posts
Re: jquery datalist
Apr 18, 2012 01:11 PM|LINK
How to opened this project? Because returns error:
Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: Could not load type 'WebAppSampleGridview.Default'.
Source Error:
Line 1: <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebAppSampleGridview.Default" %> Line 2: Line 3: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">Yanping Wang...
Star
14919 Points
1537 Posts
Microsoft
Re: jquery datalist
Apr 24, 2012 07:38 AM|LINK
Hi programercek,
I modified your javascript code towards your businesses, please go throught it:
<script type="text/javascript"> $(document).ready(function () { $("[id*=DataList1]input[type=text][id*=txtStake]").keyup(function (e) { var sum1 = $(this).val(); var sum2 = $(this).closest('tr').find("[id*=lblStake]").text(); $(this).closest('tr').find("[id*=lblStake]").text(sum1 * sum2); }); }); </script>Calculating GridView Fields Using jquery, please refer http://weblogs.asp.net/yousefjadallah/archive/2012/01/17/calculating-gridview-fields-using-jquery.aspx
Feedback to us
Develop and promote your apps in Windows Store
asteranup
All-Star
30184 Points
4906 Posts
Re: jquery datalist
Apr 24, 2012 08:16 AM|LINK
Hi,
You can get some idea from this post-
http://forums.asp.net/p/1712119/4560631.aspx/1?Re+sum+of+text+boxes+in+gridview+using+jQuery
http://delicious.com/anupdg/grandtotal
Anup Das Gupta
Mark as Answer if you feel so. Visit My Blog