Click here to Skip to main content
15,892,161 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a textbox in which some items are splitted by character #.

eg: a#b#c#d#e are entered in textBox1

now by clicking a button these item must be entered in other textbox.

eg

a in textBox2
b in textBox3
c in textBox4
d in textBox5
e in textBox6

Plz help asap

Thanks
Posted
Comments
CHill60 23-Apr-14 13:58pm    
What have you tried so far? Post the code behind your button
ZurdoDev 23-Apr-14 15:24pm    
This is very easy to do. Where are you stuck?

Split the TextBox value and assign it to other TextBoxes.
C#
string[] values = textBox1.Text.Split('#');
textBox2.Text = values[0];
textBox3.Text = values[1];
textBox4.Text = values[2];
textBox5.Text = values[3];
textBox6.Text = values[4];
 
Share this answer
 
For this you can make use of Split function available. Below is a sample code.

For testing i have added one textbox where i can enter data, a button and two textbox where data will be populated. After hitting button, you can use below code to populate.

C#
protected void Button1_Click(object sender, EventArgs e)
       {
           string text = TextBox1.Text;

           string [] text2 = text.Split('#');

           int i = 1;

           foreach (string item in text2)
           {
               if (i==1)
               {
                   TextBox2.Text = item;
               }
               else if(i==2)
               {
                   TextBox3.Text = item;
               }

               i++;

           }


       }


Please mark as answer if it helps!!!
 
Share this answer
 
v2

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