![]()
Article posted by
Me_Himanshu on 6/6/2012 | Views: 3016 | Category:
ASP.NET AJAX | Level: Beginner |
Points: 250
If you found
plagiarised (copied) or inappropriate content,
please
let us know the original source along with your correct email id (to communicate) for further action.
I was developing an order from for my client.There was a 5 fields-:Customer name,Item,Quantity ordered,Rate of the item and total amount(i.e quantity* rate).The order is to be taken by admin of the website.
Earlier the requirement was that the admin will enter each item individually.
i.e if a single customer gives order of 10 items ,each item is to be inserted individually,and the total amount(rate * quantity) is to be multiplied and displayed in the page.That was quite easy and i have completed with simple function in javascript.But the trouble arised when user changed his requirement.Now the requirement was he want to enter multiple items for the same customer,and as soon as he click place order button,the data should be inserted in database.Everything was done,but i faced a bit trouble in multiplying the textboxes value in repeater.i crawled the google,but failed to find the worthful stuff.Finall i managed it.see how
Download
Download source code for Multiplication of two textboxes in modal popup extender repeater control having repeater control without javascript
Introduction
Now here i will show you how to multiply two textboxes value and display in third that to in modal popup extender having repeater control
Using the code
<asp:Repeater ID="Repeater1" runat="server" OnItemDataBound="bound" OnItemCommand="Repeater1_ItemCommand">
<HeaderTemplate>
<table><tr>
<th>Item
</th><th>Qty Ordered
</th><th>Rate
</th><th>Amount
</th></tr></HeaderTemplate><ItemTemplate>
<tr>
<td>
<asp:TextBox ID="txtBookTitle" ValidationGroup="aa" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Item") %>'></asp:TextBox><asp:AutoCompleteExtender ID="AutoCompleteExtender2" EnableCaching="true" runat="server"MinimumPrefixLength="1" CompletionSetCount="20" CompletionListHighlightedItemCssClass="AutoCompleteFlyoutHilightedItem"CompletionListItemCssClass="AutoCompleteFlyoutItem" CompletionInterval="1000"ServiceMethod="GetItemList" ServicePath="~/WebService2.asmx" TargetControlID="txtBookTitle"></asp:AutoCompleteExtender></td><td>
<asp:TextBox ID="txtISBN" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Qty") %>'></asp:TextBox><asp:RequiredFieldValidator ID="reqqntyorder" runat="server" ValidationGroup="aa"ErrorMessage="*" ControlToValidate="txtISBN"></asp:RequiredFieldValidator></td><td>
<asp:TextBox ID="txtrate" runat="server" OnTextChanged="multiply" AutoPostBack="true"Text='<%#DataBinder.Eval(Container.DataItem,"Rate") %>'></asp:TextBox></td><td>
<asp:TextBox ID="txttotalprice" runat="server" Enabled="false" Font-Bold="true" Font-Size="Larger"Text='<%#DataBinder.Eval(Container.DataItem,"TotalCost") %>'></asp:TextBox></td><td>
<asp:Button ID="btnAddAnother" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Button") %>'CommandName='<%# DataBinder.Eval(Container.DataItem, "Button") %>' /></td></tr></ItemTemplate><FooterTemplate>
</table></FooterTemplate></asp:Repeater>
dont forget to set autopostback propert of one of textbox to trueprotected
void multiply(object sender, EventArgs e){
foreach (RepeaterItem order in Repeater1.Items){
TextBox rate = order.FindControl("txtrate") as TextBox;TextBox qnty = order.FindControl("txtISBN") as TextBox;TextBox amt = order.FindControl("txttotalprice") as TextBox;amt.Text =
Convert.ToString((Convert.ToInt32(rate.Text)) * (Convert.ToInt32(qnty.Text)));ModalPopupExtender1.Show();
}
}
Conclusion
That is how you can multipl two values in repeater control and display in another
Reference
In case of any problem please mail me to audacious.himanshu@gmail.com
If you like this article, subscribe to our
RSS Feed. You can also subscribe via email to our Interview Questions, Codes and Forums section.
Found interesting? Add this to: