在运行时将未绑定的 Gridview 列值转换为小写

发布于 2025-01-04 01:57:37 字数 864 浏览 5 评论 0原文

我有一个未绑定的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

妥活 2025-01-11 01:57:37

据我所知, 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)

南七夏 2025-01-11 01:57:37

你是否尝试过这样做:

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

然后使用 strLower 作为小写字符串。

have you tried to do this:

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

and then use the strLower as the lower case string.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文