hi,
i have listview and inside listview i have 2 textbox, auto postback of both textbox is true and textbox textchanged event i call the following method which take textbox value 1 and multiply with textbox value 2 and show it in textbox 3 its working fine.
i want when use type in textbox one and press tab so focus should go to next textbox which is in next column of listview please advice
foreach (ListViewItem item in ListView1.Items)
{
//make vairables and get control value inside listview in variable to be call for calculation
TextBox QTY = (TextBox)item.FindControl("TextBox1");
TextBox ItemPrice = (TextBox)item.FindControl("TextBox2");
TextBox TotalPrice = (TextBox)item.FindControl("TextBox3");
if (QTY.Text != "0" && ItemPrice.Text != "0" && QTY.Text != string.Empty && ItemPrice.Text != string.Empty)
{
// make int or decimal variable to multiply QTY and Item Price textbox value == i conver both QTY and Item Price textbox to int using int.parse method
int totalprice = int.Parse(QTY.Text) * int.Parse(ItemPrice.Text);
TotalPrice.Text = totalprice.ToString();
}
}
<asp:ListView ID="ListView1" runat="server" DataSourceID="SqlDataSource1">
<ItemTemplate>
<%-- //ajax update panel to have asyn call--%>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<table style="width: 100%;">
<tr>
<td>
Item: <asp:Label ID="Label4" runat="server" Text='<%# Eval("CategoryName") %>'></asp:Label>
</td>
<td>
QTY: <asp:TextBox ID="TextBox1" runat="server" AutoPostBack="true" ontextchanged="TextBox1_TextChanged" Text="0" ></asp:TextBox>
</td>
<td>
Item Price: <asp:TextBox ID="TextBox2" runat="server" AutoPostBack="true" ontextchanged="TextBox2_TextChanged" Text="0" ></asp:TextBox>
</td>
<td>
Total:(QTY X Item Price) <asp:TextBox ID="TextBox3" runat="server" Enabled='false'></asp:TextBox>
</td>
</tr>
</table>
</ContentTemplate>
<%--// trigger to call textbox change event on asyn call--%>
<Triggers >
<asp:AsyncPostBackTrigger ControlID ="TextBox1" EventName ="TextChanged" />
<asp:AsyncPostBackTrigger ControlID ="TextBox2" EventName ="TextChanged" />
</Triggers>
</asp:UpdatePanel>
</ItemTemplate>
</asp:ListView>