正确的C#代码:
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if(e.Row.RowIndex != -1 && ViewState["myDS"] != null){
            DataSet ds = (DataSet)ViewState["myDS"];
            for(int i=0;i<e.Row.Cells.Count;i++){
                if (i >=7 && i<=9)
                {
                    string str1 = ((Label)e.Row.Cells[i].Controls[1]).Text;
                    string str2 = "";
                    switch (i)
                    {
                        case 7:
                            str2 = ds.Tables[0].Rows[e.Row.RowIndex]["bet365_hwin"].ToString();
                            break;
                        case 8:
                            str2 = ds.Tables[0].Rows[e.Row.RowIndex]["bet365_draw"].ToString();
                            break;
                        case 9:
                            str2 =ds.Tables[0].Rows[e.Row.RowIndex]["bet365_awin"].ToString();
                            break;
                    }
                    if (str1 != str2)
                    {
                        double N1 = double.Parse(str1);
                        double N2 = double.Parse(str2);                        if (N1 != N2)
                        {
                            if (N1 > N2)
                            {
                                e.Row.Cells[i].BackColor = System.Drawing.Color.DarkSeaGreen;
                            }
                            else
                            {
                                e.Row.Cells[i].BackColor = System.Drawing.Color.Pink;
                            }
                        }                    }
                }
            }
        }
    }转成VB.NET代码后运行效果不同,代码如下:
 Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs)
        If e.Row.RowIndex <> -1 And Not (ViewState("myDS") Is Nothing) Then
            Dim ds As DataSet = CType(ViewState("myDS"), DataSet)
            Dim i As Integer
            For i = 0 To e.Row.Cells.Count - 1
                If i >= 7 And i <= 9 Then
                    Dim str1 As String = CType(e.Row.Cells(i).Controls(1), Label).Text
                    Dim str2 As String = ""
                    Select Case i
                        Case 7
                            str2 = ds.Tables(0).Rows(e.Row.RowIndex)("bet365_hwin").ToString()
                        Case 8
                            str2 = ds.Tables(0).Rows(e.Row.RowIndex)("bet365_draw").ToString()
                        Case 9
                            str2 = ds.Tables(0).Rows(e.Row.RowIndex)("bet365_awin").ToString()
                    End Select
                    If str1 <> str2 Then
                        Dim N1 As Double = Double.Parse(str1)
                        Dim N2 As Double = Double.Parse(str2)                        If N1 <> N2 Then
                            If N1 > N2 Then
                                e.Row.Cells(i).BackColor = System.Drawing.Color.Green
                            Else
                                e.Row.Cells(i).BackColor = System.Drawing.Color.Red
                            End If
                        End If
                    End If
                End If
            Next i
        End If
    End Sub我转成VB.NET后运行后和上面代码效果不一样,请问这段VB.NET代码哪里没转对,正确的应该是怎样的,谢谢!