Click here to Skip to main content
16,012,168 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Dear All,

I have a gridview and in the footer i have dropdownlist and textboxes. i have 2 dropdown list and 3 textboxes.i enter the item qty , mrp and now i want to do the calculation in the next textbox.

Please help me out.

Regards,
Venga
Posted

<pre lang="cs">protected void GridView2_RowDataBound(object sender, GridViewRowEventArgs e)
    {


C#
if (e.Row.RowType == DataControlRowType.Footer)
           {

   Testbox t1= (Testbox )e.Row.FindControl("id of the textbox1");
   Testbox t2= (Testbox )e.Row.FindControl("id of the textbox2");
   Testbox t3= (Testbox )e.Row.FindControl("id of the textbox3");
   Testbox t4= (Testbox )e.Row.FindControl("id of the textbox4");
  float total=float.parse(t1.text+t2.text+t3.text);
   t4.Text = total.tostring();
           }


}



if you have any button click event do this at event

command name="calculate"

C#
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
  {


if (e.CommandName == "calculate")
{

ImageButton img = (ImageButton)e.CommandSource as ImageButton;
GridViewRow grid = img.NamingContainer as GridViewRow;

Testbox t1= (Testbox )e.Row.FindControl("id of the textbox1");
Testbox t2= (Testbox )e.Row.FindControl("id of the textbox2");
Testbox t3= (Testbox )e.Row.FindControl("id of the textbox3");
Testbox t4= (Testbox )e.Row.FindControl("id of the textbox4");
C#
float total=float.parse(t1.text+t2.text+t3.text);
            t4.Text = total.tostring();


}
}
 
Share this answer
 
v4
Comments
mvengaqua 26-Nov-13 6:15am    
i dont have any button. i want the calculation as soon as i press tab on the textbox. and fill the value in the next textbox.
Can you tell me properly how the calculation should be done so that i can help.
 
Share this answer
 
Comments
mvengaqua 18-Jul-14 0:53am    
i have item rate in one textbox and item qty in the other textbox. when i enter the qty and press tab total amount should come in the next textbox.
Dear Piyush,

I select the item from the dropdownlist. Then i enter the qty of that item, and then the MRP and then i want the multiplication of qty & MRP in the next textbox. All this happening in the footer.

Regards,
Venga
 
Share this answer
 
Comments
mvengaqua 27-Nov-13 6:04am    
Dear Piyush,

I am waiting for some help from your side. What more do u want to know.

Regards,
Venga

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900