This is a migrated thread and some comments may be shown as answers.

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

6 Answers 202 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Noha
Top achievements
Rank 1
Noha asked on 21 May 2012, 12:07 PM
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 

6 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 21 May 2012, 12:16 PM
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.
0
Noha
Top achievements
Rank 1
answered on 21 May 2012, 12:20 PM
@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
0
Princy
Top achievements
Rank 2
answered on 22 May 2012, 05:27 AM
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.
0
Noha
Top achievements
Rank 1
answered on 22 May 2012, 09:02 AM
@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 ?
0
Accepted
Vasil
Telerik team
answered on 22 May 2012, 12:52 PM
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.
0
Noha
Top achievements
Rank 1
answered on 22 May 2012, 01:19 PM
Thank you Vasil, yes you're right. 


Tags
General Discussions
Asked by
Noha
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Noha
Top achievements
Rank 1
Vasil
Telerik team
Share this question
or