从文本框添加网格中的列 [英] Add columns in grid from textbox

查看:96
本文介绍了从文本框添加网格中的列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网格,这已经有这样的数据



 Column3 Column4 
123 345
1345 235





现在我想再从文本框添加两列到网格,例如,如果我在文本框中复制这些数据,那么想要添加这个网格中的数据



 excelcol1 excelcol2 
345 abc
1234 abc





。网格看起来像这样



 Column3 Column4 excelcol1 excelcol2 
123 345 345 abc
1345 235 1234 abc





how我这样做了吗?



我尝试了什么:



当我这样做

受保护的Sub Button2_Click(发件人为对象,e为EventArgs)处理Button2.Click 
Dim test As New BoundField()
test.DataField = < span class =code-string> 新的DATAfield名称
test.HeaderText = 新标题
gv_Receipts.Columns.Add(test)
结束次级





这个只添加标题,因为我想要文本框中的数据e..g数据文本框中的数据是这样的



 excelcol1 excelcol2 
345 abc
1234 abc





然后我想要这个数据与网格中的列名



我怎么做?

解决方案

参见< a href =https://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridviewrowcollection(v=vs.110).aspx> GridViewRowCollection类(System.Web.UI.WebControls ) [ ^ ]。

I have a grid and this already have data like this

Column3 Column4
123     345
1345    235



now i want to add two more columns from textbox to grid e.g if i copy this data in textbox then want to add this data in grid

excelcol1  excelcol2
   345        abc
  1234        abc




after adding textbox data in grid .. grid looks like this

Column3 Column4 excelcol1  excelcol2
123     345     345         abc
1345    235     1234        abc



how i do this ?

What I have tried:

when i do this

Protected Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
       Dim test As New BoundField()
       test.DataField = "New DATAfield Name"
       test.HeaderText = "New Header"
       gv_Receipts.Columns.Add(test)
   End Sub



this add only header where as i want what ever the data in textbox e..g data in textbox is like this

excelcol1  excelcol2
   345        abc
  1234        abc



then i want to this data with columnnames in grid

how i do this ?

解决方案

See GridViewRowCollection Class (System.Web.UI.WebControls)[^].


这篇关于从文本框添加网格中的列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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