<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方法就好了。
谢谢!
__________________________________________________________________________
本文介绍了一种从ASP.NET Datagrid控件中获取Checkbox和Textbox值的方法,并解决了页面加载时值未更新的问题。
1215

被折叠的 条评论
为什么被折叠?



