Click here to Skip to main content
15,912,977 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Posted
Updated 4-Jan-15 18:27pm
v4
Comments
King Fisher 5-Jan-15 0:25am    
not Clear
Member 11270220 5-Jan-15 0:27am    
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 comment
C#
DataTable 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);
}
 
Share this answer
 
v4
Comments
Member 11270220 5-Jan-15 0:39am    
I am using following code to do that whats next

string aaa= Textbox1.Text;
DataTable dt = new DataTable();
dt.Columns.Add("ABCD", typeof(string));
dt.Rows.Add(aaa);
George Jonsson 5-Jan-15 0:44am    
That gives you one row. I thought you wanted multiple rows?
Member 11270220 5-Jan-15 0:45am    
ya
George Jonsson 5-Jan-15 0:55am    
Maybe you can try for yourself now.
Training wheels off.
i hope its help for u

pls try to solution




XML
<asp:TextBox
                  ID="TextBox7" runat="server" AutoPostBack="true"
                  OnTextChanged="TextBox7_TextChanged" Height="23px" Width="151px" TextMode="MultiLine" ></asp:TextBox>
 
Share this answer
 

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