如何在textchange事件中获取C#中gridview文本框的值? [英] How to get value of textbox of gridview in C# in textchange event?

查看:74
本文介绍了如何在textchange事件中获取C#中gridview文本框的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello,
How to get value of TextBox of GridView in RowEditing and I've textchange event and that textbox value need to update via gridview to database. but before updating we need to calculate that value.





在RowUpdating中我们正常得到值,但在函数计算A()我没有得到文本框的值。并且需要计算该值并在同一文本框中显示已编辑的值。请帮我。这很紧急。

提前谢谢你...



我尝试过的事情:





In RowUpdating we get value normally but in function calculationA() i'm not getting value of textbox. and need to calculate that value and show edited value in same textbox also. Please help me. It's an urgent.
Thank you in advance...

What I have tried:

public void calculationA()
    {
        TextBox txt_BCICU = (TextBox)grdlist.FindControl("txt_BCICU");
        TextBox txt_BCSupDlx = (TextBox)grdlist.FindControl("txt_BCSupDlx");
        txt_TotalChargeA.Text = (Convert.ToDecimal(txt_BCSupDlx.Text.Trim()) + Convert.ToDecimal(txt_BCICU.Text.Trim())).ToString();
 
protected void txt_BCICU_TextChanged(object sender, EventArgs e)
    {
        calculationA();
    }
 
protected void grdlist_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        TextBox txt_BCICU = (TextBox)grdlist.Rows[e.RowIndex].FindControl("txt_BCICU");
        TextBox txt_BCSupDlx = (TextBox)grdlist.Rows[e.RowIndex].FindControl("txt_BCSupDlx");
    }

推荐答案

您基本上可以使用行命令事件,但是因为您的问题显示您想要执行此操作文本更改事件,然后下面是您的解决方案。

GridView内部的TextBox更改事件 - DotNetFunda.com [ ^ ]
You can basically do with row command events,But as your question shows that you want to do it in text changed events then below is the solution for you.
TextBox Change Event Inside GridView - DotNetFunda.com[^]


这篇关于如何在textchange事件中获取C#中gridview文本框的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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