Click here to Skip to main content
15,881,204 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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..


XML
<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..
Posted

narendrarathod wrote:
No overload for method 'ToString' takes '1' arguments"


narendrarathod wrote:
DataBinder.Eval(Container.DataItem,"newsdate").ToString(ConfigurationManager.AppSettings["DATE_FORMAT"].Replace("{0:", "")


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.
 
Share this answer
 
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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900