473,327 Members | 2,118 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

some databinding techniqes neede using in listview -

Hi colleagues,

I hope someone have experience with these databinding techniques in
aspx... and can explain me the reason?

I've got a listview and I would like to fix these #3 problems just to
learn how to do it...

can someone help me what is wrong in my code? I won't get squeezed
line or whatever.. so the syntax looks correct.

( 1 )
this works
<td><%# ((DateTime)Eval("DeliveredDate")).ToShortDateStrin g()%></td>

I would like to do - put date in dd-MMM-yyy
<td><%# ((DateTime)Eval("DeliveredDate")).ToShortDateStrin g("dd-MMM-
yyyy")%></td>

result: CS1501: No overload for method 'ToShortDateString' takes '1'
arguments.
why? how can I get dd-MMM-yyy?????
( 2 )
this works
<td><%# GetCityDescription("Amsterdam")%></td>

I would like to pass in by Eval("flexible city here")
<td><%# GetCityDescription(Eval("City"))%></td>

result: GetCityDescription(string)' has some invalid arguments

NOTE: GetcityDescription is a protected function in code behind...

why can't I use Eval?????? how can I fix this?
( 3 )
this works <td><%# Eval("OrderDate").ToString()%></td>
but I would like to get in dd-MMM-yyyy
<td><%# Eval("OrderDate").ToString("dd-MMM-yyyy")%></td>

I get this error: CS1501: No overload for method 'ToString' takes '1'
arguments
Can someone explain me why I get these errors? I mean why can't I do
these? I would like to understand the reason??
the last thing maybe in the dates what happens if the fields contains
null or are blanks (no date in the table) will that dump? How can I
avoid this than too :)

thanks
mesut
Aug 11 '08 #1
3 1812
Comments inline:

mesut wrote:
Hi colleagues,

I hope someone have experience with these databinding techniques in
aspx... and can explain me the reason?

I've got a listview and I would like to fix these #3 problems just to
learn how to do it...

can someone help me what is wrong in my code? I won't get squeezed
line or whatever.. so the syntax looks correct.

( 1 )
this works
<td><%# ((DateTime)Eval("DeliveredDate")).ToShortDateStrin g()%></td>

I would like to do - put date in dd-MMM-yyy
<td><%# ((DateTime)Eval("DeliveredDate")).ToShortDateStrin g("dd-MMM-
yyyy")%></td>

result: CS1501: No overload for method 'ToShortDateString' takes '1'
arguments.
why? how can I get dd-MMM-yyy?????

The function ToShortDateString will return a predefined formatted
string. You want to use toString(format String) to return the format
you want. The applicable format strings for date are found at

http://msdn.microsoft.com/en-us/library/az4se3k1.aspx

>

( 2 )
this works
<td><%# GetCityDescription("Amsterdam")%></td>

I would like to pass in by Eval("flexible city here")
<td><%# GetCityDescription(Eval("City"))%></td>

result: GetCityDescription(string)' has some invalid arguments

NOTE: GetcityDescription is a protected function in code behind...

why can't I use Eval?????? how can I fix this?
Not close to VS at present but you want to look for page methods as the
cure for this problem.
>
( 3 )
this works <td><%# Eval("OrderDate").ToString()%></td>
but I would like to get in dd-MMM-yyyy
<td><%# Eval("OrderDate").ToString("dd-MMM-yyyy")%></td>

I get this error: CS1501: No overload for method 'ToString' takes '1'
arguments
You need to cast "OrderDate" to a date to be able to use the format
string (see above for applicable string values"

>

Can someone explain me why I get these errors? I mean why can't I do
these? I would like to understand the reason??
the last thing maybe in the dates what happens if the fields contains
null or are blanks (no date in the table) will that dump? How can I
avoid this than too :)

thanks
mesut

LS
Aug 11 '08 #2
On 11 Aug, 16:17, mesut <mesut.de...@noveonbe.comwrote:
Hi colleagues,

I hope someone have experience with these databinding techniques in
aspx... and can explain me the reason?

I've got a listview and I would like to fix these #3 problems just to
learn how to do it...

can someone help me what is wrong in my code? I won't get squeezed
line or whatever.. so the syntax looks correct.

( 1 )
this works
*<td><%# ((DateTime)Eval("DeliveredDate")).ToShortDateStrin g()%></td>

I would like to do *- put date in dd-MMM-yyy
*<td><%# ((DateTime)Eval("DeliveredDate")).ToShortDateStrin g("dd-MMM-
yyyy")%></td>

result: CS1501: No overload for method 'ToShortDateString' takes '1'
arguments.
why? how can I get dd-MMM-yyy?????

( 2 )
this works
<td><%# GetCityDescription("Amsterdam")%></td>

I would like to pass in by Eval("flexible city here")
<td><%# GetCityDescription(Eval("City"))%></td>

result: GetCityDescription(string)' has some invalid arguments

NOTE: GetcityDescription is a protected function in code behind...

why can't I use Eval?????? *how can I fix this?

( 3 )
this works <td><%# Eval("OrderDate").ToString()%></td>
but I would like to get in dd-MMM-yyyy
<td><%# Eval("OrderDate").ToString("dd-MMM-yyyy")%></td>

I get this error: CS1501: No overload for method 'ToString' takes '1'
arguments

Can someone explain me why I get these errors? I mean why can't I do
these? I would like to understand the reason??

the last thing maybe in the dates what happens if the fields contains
null or are blanks (no date in the table) will that dump? How can I
avoid this than too :)

thanks
mesut
In addition to what Lloyd has said the key point here is that the
Eval() function returns an object which has to be cast to the required
type. Normally the DataBinder does this for you but if you have more
complex expressions requiring intermediate evaluation steps then you
have to embed type casting or conversion methods in the <%# ... %>
expression.

In your case (2) your could try
GetCityDescription(Eval(<cityName>).ToString())
Aug 11 '08 #3
thank you very much LS and Stan.

thanks to the information you sent I solved the problem.

many thanks again...
mesut
Aug 12 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: suz | last post by:
Hey, I have a collection with custom objects. That collection is bounded to a listview (I used the article of Lhotka). The listview is also sortable. I have also textboxes bound to the same...
0
by: Paddy | last post by:
In the case of a listView, how would the lines below have to be altered? Thanks, Paddy private void MainForm_Load(object sender, System.EventArgs e) { City cityChoices = {new...
0
by: Art Guerra | last post by:
Any tips or information would be most appreciated! Here is my scenario simplified: I have a main application form (Form1) and on that form is a listView control. On a separate form (Form2), the...
6
by: John Bailey | last post by:
I have a web page with a formview, and a multiview in the formview. When I databind the values inside the multiview views, there is no option for two-way databinding. The form populates fine, but...
3
by: John Bailey | last post by:
When I first built a few web pages in ASP .Net 2.0, I thought it was great. The formview and detailview contorls would automatically layout the controls for you, the update methods were...
1
by: tmaster | last post by:
Within a class, can I create a property that is a listview? Here's what I tried, but it doesn't seem to work: '------------ create property to give the second form access to the first form's...
0
by: Andre Viens | last post by:
Hello, I am using the following variation of code from <http://support.microsoft.com/default.aspx?scid=kb;EN-US;319340> to add icons to an imagelist for use in a listview: Private Structure...
9
by: Dennis | last post by:
I have tried using Databinding for my application but always seem to find it very restrictive (maybe I don't completely understand it enough). I always seem to find it much easier to display a...
0
by: Wayne Sepega | last post by:
I have the following Object DataSource <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="GetCustomer" TypeName="Customers" DataObjectTypeName="Customer"...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.