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

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方法就好了。
謝謝!
__________________________________________________________________________
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章