|
 |
|
Asp.net VB เช็ค radio button ในกริดวิว ว่าตอบทุกข้อหรือยัง ถ้ายังไม่ตอบ ให้มีเตือน |
|
 |
|
|
 |
 |
|

Code (VBScript)
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
Dim chkCusID1 As RadioButton
Dim chkCusID2, chkCusID3, chkCusID4, chkCusID5, chkCusID6, chkCusID7, chkCusID8, chkCusID9 As RadioButton
Dim i As Integer
lblsCore.Text = ""
For i = 0 To GridView1.Rows.Count - 1
chkCusID1 = CType(GridView1.Rows(i).FindControl("c1"), RadioButton)
chkCusID2 = CType(GridView1.Rows(i).FindControl("c2"), RadioButton)
chkCusID3 = CType(GridView1.Rows(i).FindControl("c3"), RadioButton)
chkCusID4 = CType(GridView1.Rows(i).FindControl("c4"), RadioButton)
chkCusID5 = CType(GridView1.Rows(i).FindControl("c5"), RadioButton)
chkCusID6 = CType(GridView1.Rows(i).FindControl("c6"), RadioButton)
chkCusID7 = CType(GridView1.Rows(i).FindControl("c7"), RadioButton)
chkCusID8 = CType(GridView1.Rows(i).FindControl("c8"), RadioButton)
chkCusID9 = CType(GridView1.Rows(i).FindControl("c9"), RadioButton)
lblID = CType(GridView1.Rows(i).FindControl("lbl2"), Label)
If chkCusID1.Checked = True Then
'*** Have lblID.Text ***'
Me.lblsCore.Text = "1.00"
lblidcore.Text = lblID.Text
score = CDbl(lblsCore.Text)
' insertdetail()
ElseIf chkCusID2.Checked = True Then
'*** Have lblID.Text ***'
Me.lblsCore.Text = "1.50"
lblidcore.Text = lblID.Text
score = CDbl(lblsCore.Text)
' insertdetail()
ElseIf chkCusID3.Checked = True Then
'*** Have lblID.Text ***'
Me.lblsCore.Text = "2.00"
lblidcore.Text = lblID.Text
score = CDbl(lblsCore.Text)
' insertdetail()
ElseIf chkCusID4.Checked = True Then
'*** Have lblID.Text ***'
Me.lblsCore.Text = "2.50"
lblidcore.Text = lblID.Text
score = CDbl(lblsCore.Text)
' insertdetail()
ElseIf chkCusID5.Checked = True Then
'*** Have lblID.Text ***'
Me.lblsCore.Text = "3.00"
lblidcore.Text = lblID.Text
score = CDbl(lblsCore.Text)
' insertdetail()
ElseIf chkCusID6.Checked = True Then
'*** Have lblID.Text ***'
Me.lblsCore.Text = "3.50"
lblidcore.Text = lblID.Text
score = CDbl(lblsCore.Text)
' insertdetail()
ElseIf chkCusID7.Checked = True Then
'*** Have lblID.Text ***'
Me.lblsCore.Text = "4.00"
lblidcore.Text = lblID.Text
score = CDbl(lblsCore.Text)
' insertdetail()
ElseIf chkCusID8.Checked = True Then
'*** Have lblID.Text ***'
Me.lblsCore.Text = "4.50"
lblidcore.Text = lblID.Text
score = CDbl(lblsCore.Text)
'insertdetail()
ElseIf chkCusID9.Checked = True Then
'*** Have lblID.Text ***'
Me.lblsCore.Text = "5.00"
lblidcore.Text = lblID.Text
score = CDbl(lblsCore.Text)
' insertdetail()
ElseIf chkCusID1.Checked = False And chkCusID2.Checked = False And chkCusID3.Checked = False And chkCusID4.Checked = False And chkCusID5.Checked = False And chkCusID6.Checked = False And chkCusID7.Checked = False And chkCusID8.Checked = False And chkCusID9.Checked = False Then
GridView1.BackColor = Drawing.Color.Blue
End If
runid_core()
insertdetail()
Next
Private Sub insertdetail()
Dim idhole As String = ""
Dim sum As Double = 0
Dim crsState As String = ""
Dim sqlAddCrs As String = ""
Dim sqlAddDtl As String = ""
Dim cmd As New SqlCommand
Dim dsChk As New DataSet
Dim addChk As Boolean = True
For i = 0 To GridView1.Rows.Count - 1
sqlAddCrs = "INSERT INTO Score_core VALUES('" & txtRunid.Text & "','" & lblidcore.Text & "','" & TextEvaluator.Text & "'," & lblsCore.Text & ",'" & TextEvaluatee.Text & "')"
Label8.Text = (sqlAddCrs)
Try
With cmd
.CommandType = CommandType.Text
.CommandText = sqlAddCrs
.Connection = conn
.ExecuteNonQuery()
End With
Catch ex As Exception
Label6.Text = ex.Message
Exit Sub
End Try
Next
End Sub
Tag : .NET, Ms SQL Server 2008, VBScript, Web (ASP.NET)

|
|
 |
 |
 |
 |
Date :
2013-07-01 15:41:24 |
By :
T__T |
View :
965 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ใช้พวก Validation Control ของ ASP.Net ได้หรือเปล่าครับ 
|
 |
 |
 |
 |
Date :
2013-07-04 06:27:39 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 01
|