Check is RadNumericTextBox(s) changed at server side using C#

7 posts, 1 answers
  1. Noha
    Noha avatar
    30 posts
    Member since:
    Sep 2010

    Posted 21 May 2012 Link to this post

    Dear Telerik Team

    I have a RadGrid with GridTemplateColumn that have a  RadNumericTextBox as an ItemTemplate.

    The user has the ability to change the values on the RadNumericTextBox.

    On Save button click, I Foreach the RadGrid to save the updated values to Database.

    The Question is:
    How to check if the value of the RadNumericTextBox is changed or not at server side using C# ?

    Thanks 
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 21 May 2012 Link to this post

    Hello Noha,

    Try the following code.
    C#:
    protected void Button2_Click(object sender, EventArgs e)
    l{
        foreach (GridDataItem item in RadGrid1.MasterTableView.Items)
       {
           RadNumericTextBox txt = (RadNumericTextBox)item.FindControl("RadNumericTextBox3");
           string value = txt.Text;
         }
    }

    Thanks,
    Princy.
  3. Noha
    Noha avatar
    30 posts
    Member since:
    Sep 2010

    Posted 21 May 2012 Link to this post

    @Princy

    Thank you!

    Yes I do that to access the value of the textbox at server side.

    But, the next step is how i can check if this textbox changed or not ???
    that is my confusion :S
  4. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 22 May 2012 Link to this post

    Hello Noha,

    You can attach TextChanged event as shown below.
    aspx:
    <telerik:RadNumericTextBox ID="RadNumericTextBox3" runat="server" AutoPostBack="true" ontextchanged="RadNumericTextBox3_TextChanged"></telerik:RadNumericTextBox>
    C#:
    protected void RadNumericTextBox3_TextChanged(object sender, EventArgs e)
    {
        RadNumericTextBox txt = (RadNumericTextBox)sender;
        string v = txt.Value.ToString();
    }

    Thanks,
    Princy.
  5. Noha
    Noha avatar
    30 posts
    Member since:
    Sep 2010

    Posted 22 May 2012 Link to this post

    @Princy

    Thank you so much princy :) 
    by that way I can access the value changed at client side, that's ok.

    But, Finally at Save button clicked at post back to server side, How I check if this textbox is changed or not !! that's my QUESTION.

    anyway I got a silly solution, at the textchanged event fires at client side i'll set its empty message to lets say "U" means Updated 
    and at server side I'll check the empty message of the current textbox at the RadGrid.

    What do you think of that solution ?
  6. Answer
    Vasil
    Admin
    Vasil avatar
    1633 posts

    Posted 22 May 2012 Link to this post

    Hello Noha,

    Your solution will work, but please note that the Princy's one is actually for server side. RadNumericTextBox3_TextChanged is C# function written in the code behind.

    Regards,
    Vasil
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  7. Noha
    Noha avatar
    30 posts
    Member since:
    Sep 2010

    Posted 22 May 2012 Link to this post

    Thank you Vasil, yes you're right. 


Back to Top