 |
|
asp.net อยากทราบวิธีเอา ค่าจาก dropdownlist ใน gridview ใน footer มาใช้ยังไงหรือ ค่ะ vb.net ค่ะ |
|
 |
|
|
 |
 |
|
ใช้การ FindControl ปกติครับ
Code (VB.NET)
Sub myGridView_RowCommand(source As Object, e As GridViewCommandEventArgs)
If e.CommandName = "Add" Then
'*** CustomerID ***'
Dim txtCustomerID As TextBox = CType(myGridView.FooterRow.FindControl("txtAddCustomerID"), TextBox)
'*** Email ***'
Dim txtName As TextBox = CType(myGridView.FooterRow.FindControl("txtAddName"), TextBox)
'*** Name ***'
Dim txtEmail As TextBox = CType(myGridView.FooterRow.FindControl("txtAddEmail"), TextBox)
'*** CountryCode ***'
Dim txtCountryCode As TextBox = CType(myGridView.FooterRow.FindControl("txtAddCountryCode"), TextBox)
'*** Budget ***'
Dim txtBudget As TextBox = CType(myGridView.FooterRow.FindControl("txtAddBudget"), TextBox)
'*** Used ***'
Dim txtUsed As TextBox = CType(myGridView.FooterRow.FindControl("txtAddUsed"), TextBox)
strSQL = "INSERT INTO customer (CustomerID,Name,Email,CountryCode,Budget,Used) " & _
" VALUES ('" & txtCustomerID.Text & "','" & txtName.Text & "','" & txtEmail.Text & "' " & _
" ,'" & txtCountryCode.Text & "','" & txtBudget.Text & "','" & txtUsed.Text & "') "
objCmd = New OleDbCommand(strSQL, objConn)
objCmd.ExecuteNonQuery()
BindData()
End If
End Sub
|
 |
 |
 |
 |
Date :
2013-04-26 13:30:08 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
แล้วถ้า ปุ่มอยู่นอก gridview จะเรียกใช้ได้ไหมคะ
|
 |
 |
 |
 |
Date :
2013-04-26 14:13:58 |
By :
nuchkamol |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ถ้าแบบนั้นให้ใช้
Code (VB.NET)
Sub Button1_Click(sender As Object, e As EventArgs)
Dim ddl As DropDownList
ddl = DirectCast(myGridView.FooterRow.FindControl("myDDL"), DropDownList)
.
.
.
End Sub
|
 |
 |
 |
 |
Date :
2013-04-26 14:24:33 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลองแล้ว ทำไม ทำไม่ได้ก็ไม่รู้คะ TT__TT
|
 |
 |
 |
 |
Date :
2013-04-26 15:26:33 |
By :
nuchkamol |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ตรวจสอบชื่อ ของ DropDownList ครับ myDDL ว่ามันมีหรือไม่
|
 |
 |
 |
 |
Date :
2013-04-26 15:28:27 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|