如何在多行文本框中逐行获取? [英] How to get the line by line in multiline text box?
本文介绍了如何在多行文本框中逐行获取?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
海,
我正在使用多行文本框获取地址.我想将此地址逐行保存在其他列字段中.怎么做?
例如,我给地址如下
拉曼,
第一街,
钦奈.
像下面这样保存到sql table
Hai,
I am using Multiline Textbox for get Address. I want to save this address to line by line in different column field. How to do it?
For example, I am giving Address like following
Raman,
1st Street,
Chennai.
This is saved like following to sql table
Address1 Address2 Address3
Raman 1st Street Chennai
那么,如何在不同的字符串变量中逐行获取?
请帮助我...
So, How we can get line by line in different string variable?
Please help me...
推荐答案
使用 ^ ]方法,即:
Split theTextBox
''sText
property using the String.Split[^] method, that is:
string[] sep = new string[] {"\r\n"};
string[] lines = textBox.Text.Split(sep, StringSplitOptions.RemoveEmptyEntries);
您将得到一个由string
组成的数组,每个数组对应于另一行.
you get an array of string
s, each one corresponding to a different line.
您可以使用 ^ ].
示例:
You can use Regex.Split()[^] for this.
Example:
string[] lines = Regex.Split(txtAddress.Text, "\r\n");
<asp:textbox id="TextBox1" runat="server" textmode="MultiLine" height="100px" width="300px" :asp="#unknown">
<asp:button id="Button1" runat="server" text="Button" asp="#unknown" />
这篇关于如何在多行文本框中逐行获取?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文