[VB.NET]如何取得DATAGIRD里CHECKBOX和TEXTBOX的值?

本文介绍了一种从ASP.NET Datagrid控件中获取Checkbox和Textbox值的方法,并解决了页面加载时值未更新的问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

VB.NET源码-156个实用实例哦…… <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
如何取得DATAGIRD里CHECKBOX和TEXTBOX的值?
我想把DATAGRID的里的值取出来,放在一个DATATBALE里,代码如下:
Public Function dt() As DataTable
Dim i As Integer
Dim j As Integer
Dim dt1 As DataTable = New DataTable
dt1.Columns.Add(New DataColumn( delflg , Type.GetType( System.Boolean )))
dt1.Columns.Add(New DataColumn( txtMtype , Type.GetType( System.String )))
dt1.Columns.Add(New DataColumn( txtBikou , Type.GetType( System.String )))
Dim delflg As Boolean
Dim txtMtype As TextBox
Dim txtBikou As TextBox
Dim listitem As DataGridItem
max_row = Me.dgMeetingtype.Items.Count
For i = 0 To max_row - 1
listitem = Me.dgMeetingtype.Items(i)
If i < max_row - 1 Then
delflg = CType(listitem.FindControl( chkDel ),CheckBox).Checked
End If
txtMtype = CType(listitem.FindControl( txtMtype ), TextBox)
txtBikou = CType(listitem.FindControl( txtBiko ), TextBox)

Dim myRow As DataRow = dt1.NewRow()
myRow(0) = delflg
myRow(1) = txtMtype.Text
myRow(2) = txtBikou.Text
dt1.Rows.Add(myRow)
Next i
Return dt1
End Function

这样有什么不对吗?好像是CHECKBOX和TEXTBOX的值改了,我却获取不到,得到的还是绑定DATAGRID时候的值。高手帮帮忙啊~!
__________________________________________________________________________
自己顶一下,希望有高手来解决!谢谢了
__________________________________________________________________________
TextBox tb=(TextBox)datagrid1.findControl( your TextBoxid );
__________________________________________________________________________
嗯,问题已解决。
我的问题出在PAGE_LOAD里
加一个ISPOSTBACK方法就好了。
谢谢!
__________________________________________________________________________
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值