在gridview中显示sqlserver表的Date列时出错 [英] Error when showing Date column of sqlserver table in gridview

查看:116
本文介绍了在gridview中显示sqlserver表的Date列时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

错误 -



DataBinding:' System.Data.Common.DataRecordInternal'不包含名称为' CreateddDate'的财产。



代码 -

其中CreatedDate sqlserver表中的DateTime数据类型列



和aspx页面代码是----

Error--

DataBinding: 'System.Data.Common.DataRecordInternal' does not contain a property with the name 'CreateddDate'.

Code--
where "CreatedDate" of "DateTime" datatype column of in sqlserver table

and aspx page code is ----

<asp:GridView ID="Grid_PostedJobs" runat="server" AutoGenerateColumns="False" Height="175px" Width="673px" DataKeyNames="Job_Id"  >
  <Columns>
    <asp:TemplateField HeaderText="Posted Date" Visible="true">
       <ItemTemplate>
          <asp:Label ID="lbl_Date" runat="server" Text=''<%#
                 Bind("CreatedDate", "{0:M-dd-yyyy}")%>''>
          </asp:Label>
        </ItemTemplate>
    </asp:TemplateField>
</Columns>
    </asp:GridView>

推荐答案

我认为您已使用''PostedDate'重命名了CreatedDate列,如您所示的Select查询所示发布在这里:

I think you have renamed your CreatedDate column with ''PostedDate'' as shown your Select query which you have posted here:
cmd.CommandText = "select CreatedDate ''PostedDate'' ,JobTitle,Location,Job_Id,Category from JobForm ";





如果这是正确的查询,那么你必须在Data Bind方法上使用''PostedDate''而不是''CreatedDate''



If this this the right query then you have to use ''PostedDate'' on Data Bind method instead of ''CreatedDate''


这篇关于在gridview中显示sqlserver表的Date列时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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