Multiplication of two textboxes in modal popup extender repeater control having repeater control without javascript

Me_Himanshu
Posted by in ASP.NET AJAX category on for Beginner level | Points: 250 | Views : 6957 red flag
Rating: 3 out of 5  
 1 vote(s)

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 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 true


protected 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
Page copy protected against web site content infringement by Copyscape

About the Author

Me_Himanshu
Full Name: Himanshu Pandey
Member Level: Starter
Member Status: Member
Member Since: 6/6/2012 2:28:47 AM
Country: India
Himanshu Pandey
not yet
I am a avid user if this website since i started my career ,always fantasize to post some useful articles into it.I am having 2.5 years of experience in Asp.Net,C#,Sql server,JavaScript and just started m working on WCF and Linq.

Login to vote for this post.

Comments or Responses

Login to post response

Comment using Facebook(Author doesn't get notification)