As you asked "
I just want to know in textchanged event,how to get index of that Row in which i am processing that two textboxes."
Solution 2 is sufficient for you.
But what happen if you enter data in
Value first ?? You TextChanged event will be fired and start calculating
quantity * value while there is no data in quantity field.
PROBLEM!!!
Even after this if you enter data in
quantity field, TextChanged event will not fire untill you again change data in
Value field.
So its better to add a LinkButton(in same Or different column) and give it some CommandName and handle it OnRowCommand like this -
<asp:gridview runat="server" id="GridView1" onrowcommand="GridView1_RowCommand" ...="" xmlns:asp="#unknown">
...
<itemtemplate>
<asp:linkbutton id="LinkButton1" commandname="calculateTotal" commandargument="<%# Container.DisplayIndex %>" runat="server">LinkButton</asp:linkbutton>
</itemtemplate>
...
</asp:gridview>
In code behind -
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "calculateTotal")
{
int rowindex=intParse(e.CommandArgument.ToString());
int quantityfield = int.Parse(((TextBox)gv.Rows[rowindex].FindControl("txtQuantity")).Text);
int valuefield = int.Parse(((TextBox)gv.Rows[rowindex].FindControl("txtValue")).Text);
TextBox result = (TextBox)gv.Rows[rowindex].FindControl("TOTAL");
result.Text = (quantityfield * valuefield).ToString() ;
}
}
Thats All :)