如何在gridview seprate行中添加多行文本框值 [英] how to add multi line textbox values in gridview seprate rows

查看:95
本文介绍了如何在gridview seprate行中添加多行文本框值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我在gridview中创建一个应用程序,其中一个列名为Testname,一个多行文本框和提交按钮。



我想在Gridview seprate行中添加多行文本框值。

假设我在多行文本框中键入2行

hi

hello



点击提交按钮后我想在gridview中输出以下内容



测试名称



你好



想要gridview的每一行中的每一行文本框

解决方案

你可以拆分多行的值文本框,然后将每个部分添加为一行。

[更新]添加评论代码

 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(部分);
}


我希望对你有所帮助。


请尝试解决方案< br $>








 <   asp:TextBox   

ID = TextBox7 runat = server AutoPostBack = true

< span class =code-attribute> OnTextChanged = TextBox7_TextChanged 高度 = 23px < span class =code-attribute>宽度 = 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 comment

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);
}


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>


这篇关于如何在gridview seprate行中添加多行文本框值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆