Public Function CheckScore(ByVal objGv As GridView) As Boolean
Dim gvr As GridViewRow
Dim i As Integer = 0
Dim Score As Integer
Dim gvComment As String
Dim Radioname As String
Dim Textboxname As String
With objGv
Score = 0
If Score >= 0 Then
For Each gvr In .Rows
Score = -1
Dim rd10 As RadioButton
Radioname = .ID & "_10"
rd10 = CType(.Rows(i).FindControl(Radioname), RadioButton)
'Label10.Text += CStr(rd10.Checked).ToString & "<br>"
If rd10.Checked Then
'Label14.Text += .Rows(i).Cells(0).Text & rd10.Checked
'Label13.Text += "10,"
Score = 10
End If
Dim rd9 As RadioButton
Radioname = .ID & "_9"
rd9 = CType(.Rows(i).FindControl(Radioname), RadioButton)
If rd9.Checked Then
Score = 9
End If
Dim rd8 As RadioButton
Radioname = .ID & "_8"
rd8 = CType(.Rows(i).FindControl(Radioname), RadioButton)
If rd8.Checked Then
Score = 8
End If
Dim rd7 As RadioButton
Radioname = .ID & "_7"
rd7 = CType(.Rows(i).FindControl(Radioname), RadioButton)
If rd7.Checked Then
Score = 7
End If
Dim rd6 As RadioButton
Radioname = .ID & "_6"
rd6 = CType(.Rows(i).FindControl(Radioname), RadioButton)
If rd6.Checked Then
Score = 6
End If
Dim rd5 As RadioButton
Radioname = .ID & "_5"
rd5 = CType(.Rows(i).FindControl(Radioname), RadioButton)
If rd5.Checked Then
Score = 5
End If
Dim rd4 As RadioButton
Radioname = .ID & "_4"
rd4 = CType(.Rows(i).FindControl(Radioname), RadioButton)
If rd4.Checked Then
Score = 4
End If
Dim rd3 As RadioButton
Radioname = .ID & "_3"
rd3 = CType(.Rows(i).FindControl(Radioname), RadioButton)
If rd3.Checked Then
Score = 3
End If
Dim rd2 As RadioButton
Radioname = .ID & "_2"
rd2 = CType(.Rows(i).FindControl(Radioname), RadioButton)
If rd2.Checked Then
Score = 2
End If
Dim rd1 As RadioButton
Radioname = .ID & "_1"
rd1 = CType(.Rows(i).FindControl(Radioname), RadioButton)
If rd1.Checked Then
Score = 1
End If
Dim rd0 As RadioButton
Radioname = .ID & "_0"
rd0 = CType(.Rows(i).FindControl(Radioname), RadioButton)
If rd0.Checked Then
Score = 0
End If
Dim txtcomment As TextBox
Textboxname = .ID & "_comment"
txtcomment = CType(.Rows(i).FindControl(Textboxname), TextBox)
If rd0.Checked Then
'Label14.Text += .Rows(i).Cells(0).Text & "0"
'Label13.Text += "0"
gvComment = (.ID & "_comment").ToString
End If
'ds = CType(Session("ds"), DataSet)
'ds2 = CType(Session("ds"), DataSet)
Select Case objGv.ID
Case "gvchk1"
'Me.AddInspectDetail(newID, CInt(gvr.Cells(0).Text), Score, txtcomment.Text)
Case "gvchk2"
'i = i
'Dim teststr As String = gvr.Cells(0).Text
'Me.AddInspectDetail(newID, CInt(gvr.Cells(0).Text), Score, txtcomment.Text)
Case "gvchk3"
' Me.AddInspectDetail(newID, CInt(gvr.Cells(0).Text), Score, txtcomment.Text)
Case "gvchk4"
' Me.AddInspectDetail(newID, CInt(gvr.Cells(0).Text), Score, txtcomment.Text)
End Select
i += 1
'Me.AddInspectDetail(newId, CType(ds.Tables(0).Rows(i)("ItemID").ToString, Integer), Score)
'Response.Write("<script>alert('ทำการบันทึกไม่ครบกรุณากลับไปบันทึกให้ครบ');</script>")
Next
.Enabled = False
Else
Response.Write("<script>alert('ทำการบันทึกไม่ครบกรุณากลับไปบันทึกให้ครบ');</script>")
End If
End With
End Function
Tag : .NET, Ms SQL Server 2008, Web (ASP.NET), VB.NET, VS 2008 (.NET 3.x)