2012-02-08 38 views
0

我有一個未綁定的Gridview,它由Linq to Entities查詢填充,並希望將特定列中的字符串值轉換爲小寫。我試過StrConv(e.Row.Cells(3).Text, VbStrConv.ProperCase),但這不起作用。在運行時將未綁定的Gridview列值轉換爲小寫

我也在LiNQ to Entities查詢中嘗試過StrConv(emp.Name, VbStrConv.ProperCase),但仍然返回的名稱值將轉換爲小寫。

Protected Sub GridView3_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView3.RowDataBound 
      If e.Row.RowType = DataControlRowType.DataRow Then 

     For i As Integer = 0 To e.Row.Cells.Count - 1 
      Dim cellDate As Date 
      If Date.TryParse(e.Row.Cells(i).Text, cellDate) Then 
       e.Row.Cells(i).Text = String.Format("{0:d}", cellDate) 
      End If 
     Next 
    End If 
    StrConv(e.Row.Cells(4).Text, VbStrConv.ProperCase) 
End Sub 

回答

1

據我所看到的,STRCONV返回字符串,應該使用,我認爲像:

e.Row.Cells(4)。文本=中StrConv(e.Row.Cells(4) .Text,VbStrConv.ProperCase)

+0

我已經添加了代碼。下面的代碼行不能按預期工作,即將Cell(4)中的值更改爲小寫的StrConv(e.Row.Cells(4).Text,VbStrConv.ProperCase) – StackTrace 2012-02-08 11:05:22

+0

謝謝,您的代碼執行此操作。 – StackTrace 2012-02-08 12:00:53

1

你試圖這樣做:

串strLower = e.Row.Cells [0] .Text.ToLower();

然後使用strLower作爲小寫字符串。

+0

試過了,以及沒有成功 – StackTrace 2012-02-08 09:09:40