更新时间:2023-12-04 13:10:16
你可以拆分多行的值文本框,然后将每个部分添加为一行。
[更新]添加评论代码DataTable dt = new DataTable();
dt.Columns.Add( ABCD, typeof ( string ));
string parts [] = textBox1.Split( new char [] {' \ r',' \ n'},StringSplitOptions.RemoveEmptyEntries);
foreach ( string part in 部分)
{
// 通过更新网格视图中的每一部分作为一行添加数据表
dt.Rows.Add(部分);
}
我希望对你有所帮助。
请尝试解决方案< asp:TextBox
ID = TextBox7 runat = server AutoPostBack = true
OnTextChanged = TextBox7_TextChanged 高度 = 23px 宽度 = 151px TextMode = MultiLine > < / asp:TextBox > 跨度>
hi,
I create one application in that gridview with one column name Testname and one multi line text box and submit button.
I want to add multi line textbox value in Gridview seprate rows.
suppose I type 2 line in multi line textbox
hi
hello
after click on submit button I want following output in gridview
Testname
hi
hello
want each line of textbox in each row of gridview
You can split the value of the multi-line textbox and then add each part as one row.
[UPDATE] Added code from commentDataTable dt = new DataTable(); dt.Columns.Add("ABCD", typeof(string)); string parts[] = textBox1.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries); foreach (string part in parts) { // Add each part as a row in the gridview via updating the datatable dt.Rows.Add(part); }
i hope its help for u
pls try to solution<asp:TextBox ID="TextBox7" runat="server" AutoPostBack="true" OnTextChanged="TextBox7_TextChanged" Height="23px" Width="151px" TextMode="MultiLine" ></asp:TextBox>