在运行时将未绑定的 Gridview 列值转换为小写
我有一个未绑定的 Gridview,它由 Linq to Entities 查询填充,并且希望将特定列中的字符串值转换为小写。
在 Gridview 的 RowDataBound 事件中,我尝试了 StrConv(e.Row.Cells(3).Text, VbStrConv.ProperCase)
但这不起作用。
我还在 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
I have an unbound Gridview that is populated by a Linq to Entities query and would like to convert string values in a particular column to lowercase.
In the Gridview's RowDataBound event, i have tried StrConv(e.Row.Cells(3).Text, VbStrConv.ProperCase)
but this doesn't work.
I have also tried StrConv(emp.Name, VbStrConv.ProperCase)
in the LiNQ to Entities query but still the Name values returned are to converted to Lower-case.
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
据我所知, strConv 返回一个应该使用的字符串,我认为:
e.Row.Cells(4).Text = StrConv(e.Row.Cells(4).Text, VbStrConv.ProperCase)
As far as I can see, strConv returns a string, which should be used, I think like:
e.Row.Cells(4).Text = StrConv(e.Row.Cells(4).Text, VbStrConv.ProperCase)
你是否尝试过这样做:
然后使用 strLower 作为小写字符串。
have you tried to do this:
and then use the strLower as the lower case string.