方法'ToString'的重载没有接受'1'参数 [英] No overload for method 'ToString' takes '1' arguments
问题描述
你好..
我写了给定的代码,但出现错误方法'ToString'的无重载采用'1'参数",该行以粗体显示
anybory可以帮我改正吗..
hello ..
i write given code but i got error"No overload for method ''ToString'' takes ''1'' arguments" which displayed in bold line
can anybory help me to correct it..
<asp:TemplateColumn HeaderText="News Date" HeaderStyle-CssClass="dgHeaderItem">
<HeaderStyle HorizontalAlign="Left" Width="25%"></HeaderStyle>
<ItemStyle HorizontalAlign="Left" Width="25%"></ItemStyle>
<ItemTemplate>
<%#DataBinder.Eval(Container.DataItem,"newsdate").ToString(ConfigurationManager.AppSettings["DATE_FORMAT"].Replace("{0:", "").Replace("}", "")+ "," + ConfigurationManager.AppSettings["TIME+FORMAT"])%>
</ItemTemplate>
</asp:TemplateColumn>
谢谢..
Thank you..
推荐答案
方法没有重载'' ToString''接受``1''自变量''
No overload for method ''ToString'' takes ''1'' arguments"
DataBinder.Eval(Container.DataItem,"newsdate").ToString(ConfigurationManager.AppSettings ["DATE_FORMAT"].Replace("{0:,")
DataBinder.Eval(Container.DataItem,"newsdate").ToString(ConfigurationManager.AppSettings["DATE_FORMAT"].Replace("{0:", "")
错误本身是不言自明的.如果可以看到,则说明您正在执行以下操作:
abc.ToString(xyz.Replace())
这是错误的,不允许的.请更正此部分.
Error itself is self explanatory. If you can see, you are doing something like:
abc.ToString(xyz.Replace())
This is WRONG and not allowed. Please correct this part.
请查看 Eval [ ^ ].它返回一个对象.除了不带参数的对象之外,对象没有ToString的其他任何重载.
您需要先将对象转换为DateTime,然后才能访问正确的方法.
Look at the return type of Eval[^]. It returns an object. Object does not have any other overloads of ToString other than the one that takes no arguments.
You''ll need to cast your object to DateTime before being able to access the correct method.
这篇关于方法'ToString'的重载没有接受'1'参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!