Click here to Skip to main content
15,889,096 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.


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");
    }
Posted
Updated 30-Jan-18 21:43pm
Comments
Ziee-M 2-Feb-18 4:03am    
In calculation, you have to set the row index : grdlist.Rows[RowIndex].FindControl("txt_BCICU")

1 solution

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[^]
 
Share this answer
 
Comments
Nagendra Singh Kushwah 31-Jan-18 3:52am    
This is useful but my requirement is different.
Please check my code as mentioned above
public void calculationA()
{
TextBox txt_BCICU = (TextBox)grdlist.FindControl("txt_BCICU");
}

Here in txt_BCICU getting null value. I want to show old value here as I bind data in gridview.
Do you have any idea, how can I get value of textbox inside user defined function.

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