如何将grideview列与文本框相乘 [英] how to multiply a grideview column with a text box

查看:74
本文介绍了如何将grideview列与文本框相乘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经将C#与MSAccess建立了连接,现在正在显示表数据
在GridView中.我想将textbox的值与gridview(table colum)Colum相乘.这可能吗 ??我如何才能对另一个文本框中的内容进行乘除法运算.
请帮助我.. !!!!

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..!!

推荐答案



使用gridview的行数据绑定方法,并在此方法中找到gridview单元格的控件,然后将文本框值与单元格值相乘.


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
   }

 }


在gridview中添加以下事件.

< asp:gridview id ="GridView" onrowdatabound ="GridView_RowDataBound" runat ="server">
//您的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


是的,您也可以通过Java脚本在文本框发生模糊事件时执行此操作,只需检查值是否为数值,然后将其乘以网格视图单元格值即可.
要使用JavaScript访问网格视图,请参考
http://stackoverflow.com/questions/4097736/how-to- access-gridview-cell-value-with-javascript [ ^ ]

http://www.infragistics.com/community/forums/t/63319.aspx [ ^ ]
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[^]


这篇关于如何将grideview列与文本框相乘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆