是否有一种简单而甜蜜的方式.ToString L2E中的两个值? [英] Is there a simple and sweet way to .ToString two values in L2E?

查看:41
本文介绍了是否有一种简单而甜蜜的方式.ToString L2E中的两个值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿大家。

我正在寻找一个后期绑定到我网页上的链接按钮。  在我的查询中,我得到.StartTime(TimeSpan Type)和.EndTime(TimeSpan Type),但我真的想将这两个值一起显示以显示范围;从这个时间到那个时候。
 我尝试使用一些匿名函数来连接值,但后期绑定显示,

VB $ AnonymousDelegate_0`2 [System.Object,System。串。  我还尝试使用Select方法通过转换TimeSpan对象ToString将连接的值投影到匿名类型,但后来我发现ToString不是L2E中的
,因为它没有转换为T-SQL查询。

I'm looking to do a late binding to a link button on my web page.  In my query, I am getting .StartTime (TimeSpan Type) and .EndTime (TimeSpan Type), but I'd really like to display these two values together to show a span; From this time to that time.  I've tried using some anonymous function to concatenate the values, but the late binding is showing, VB$AnonymousDelegate_0`2[System.Object,System.String.  I've also tried using the Select method to project the concatenated values to an anonymous type through converting the TimeSpan objects ToString, but then I found out ToString isn't available in L2E because it doesn't translate to a T-SQL Query.

 

  Private Sub Method()
    Using Context As New EntityCollection

      Dim tCollection As ObjectSet(Of Thing) = Context.Things
      
      Dim query = (From t In tCollection
             Select New With {
               .ThingID = t.tID,
               .WidgetID = t.widgetIDFK,
               .WidgetName = t.Widget.Name,
               .StartTime = t.startTime,
               .EndTime = t.endTime,
               .Span = t.startTime.ToString & " - " & t.endTime.ToString,
               .Comments = t.comments}
             )

      gvThings.DataSource = query
      gvThings.DataBind()

    End Using
  End Sub

  ;

有没有人对这个问题有所了解?  提前致谢。  :)

Does anyone have an idea regarding this problem?  Thanks in advance.  :)

推荐答案

你好,

你 可以尝试使用以下代码片段:

You  could try with the following code snippet:

Dim query= From t In tCollection_ 
  Select t

但是当你在ASP.NET中使用GridView时,你可以创建一个模板字段,它看起来像:

But when you use GridView in ASP.NET, you could create a templete field which looks like:

        <asp:TemplateField HeaderText="TimeSpan">
          <EditItemTemplate>
            <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
          </EditItemTemplate>
          <ItemTemplate>
            <asp:Label ID="Label1" runat="server" Text='<%#Eval("startTime") %>'></asp:Label>
            <asp:Label ID="Label2" runat="server" Text=" ~ "></asp:Label>
            <asp:Label ID="Label3" runat="server" Text='<%#Eval("endTime") %>'></asp:Label>
          </ItemTemplate>
        </asp:TemplateField>

如果有帮助,请试试让我知道。顺便说一句,有关更多asp.net问题,请参阅
asp.net论坛

Please have a try and let me know if this helps. By the way, for more asp.net issues, please refer to asp.net forums.

祝你好运


这篇关于是否有一种简单而甜蜜的方式.ToString L2E中的两个值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆