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

Trying to programmatically set textbox value

3 Answers 460 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Jason
Top achievements
Rank 1
Jason asked on 12 May 2010, 08:53 PM

I use the NeedDataSource Event to bind a table from the resultset of a stored procedure. In the table I have a text box(textBox7) in which sometimes there is a visible value, other times there is not. I want to test to see if there is a value in this textbox. I
I
f there is, I want to set the value of textBox6 to "Yes". If textBox7 does not have a value, make the value of TextBox6 equal to "No". I am using the ItemDataBound event of TextBox6 to try to achieve this. Right now the value of textBox6 always ends up being "Yes" . However, this is not correct. I need to know how to write a valid test for the value of TextBox7, or if I am doing something else wrong. Code is below. Any help would be greatly appreciated.

jason

        private void textBox6_ItemDataBound(object sender, System.EventArgs e)  
        {  
 
            if (textBox7.Value != null || textBox7.Value=="")  
            {  
                textBox6.Value = "Yes";  
            }  
 
            else  
            {  
 
                textBox6.Value = "No";  
            }  
        }  
    } 

 

3 Answers, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 17 May 2010, 09:05 AM
Hi Jason,

You have modified the definition TextBox item instead of the processing counterpart (the sender argument), thus all subsequent processing items will be modeled after the modified reporting item.

Check out the following help articles:
Generally speaking for similar cases our suggestion is to use Bindings instead of Events. You can achieve your requirement as shown in the following sreenshoot:



Greetings,
Peter
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Ashish
Top achievements
Rank 1
answered on 11 Sep 2013, 01:12 PM
Hi.
I am facing same problem for  Boolean field.
How can I set the text box value =yes if true else No
0
Squall
Top achievements
Rank 1
answered on 11 Sep 2013, 04:35 PM
Tags
General Discussions
Asked by
Jason
Top achievements
Rank 1
Answers by
Peter
Telerik team
Ashish
Top achievements
Rank 1
Squall
Top achievements
Rank 1
Share this question
or