Click here to Skip to main content
14,698,679 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
i have made a connection of C# with MSAccess and i am now showing the table data
in gridview. i want to multiply a value of textbox with a gridview(table colum) Colum. Is this possible ?? how can i multiply and desplay that result in another text box.
plz help me..!!
Posted
Comments
[no name] 11-Oct-12 7:56am
   
Well yes and no. Yes you can multiply values using the * operator. No you cannot multiply the value of a textbox with a gridview column. It only makes sense to multiply numerical values.
Nandakishore G N 12-Oct-12 3:16am
   
Muhamad..s it is possible..is ther any button or some thing to multiply..just post the html code u had done...bcoz anyone can suggest..

Hi,

Use the row databound method of gridview and into this method find the control of the gridview cell and then multiply the textbox value with the cell value.


void GridView_RowDataBound(Object sender, GridViewRowEventArgs e)
 {
   if(e.Row.RowType == DataControlRowType.DataRow)
   {
     // Multiply the cell of gridview with the textbox value.
     e.Row.Cells[1].Text = (Convert.ToInt32(e.Row.Cells[1].Text) + Convert.ToInt32(textBox.Text)).ToString(); //put the cell number as position in your gridview
   }

 }

In the gridview add the below event.

<asp:gridview id="GridView" onrowdatabound="GridView_RowDataBound" runat="server">
//Your gridview code



Hope this will help you
   
v2
Comments
Muhamad Faizan Khan 7-Nov-12 5:57am
   
Please tell me with C#
Mohd. Mukhtar 7-Nov-12 6:16am
   
see the updated answer
Ya u can do it by java script also on blur event of text box just check if value is numerical then multiply it by grid view cell value.
To Access the grid view using JavaScript refer
http://stackoverflow.com/questions/4097736/how-to-access-gridview-cell-value-with-javascript[^]

http://www.infragistics.com/community/forums/t/63319.aspx[^]
   

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