Forms Data Controls :: URL Encoding / URL Safe Code Overwritten When Databind Using Eval
Nov 3, 2010
In a website I'm working on, there is a link to ~/Products/1/2%20Inch%20Tube.aspx (1/2 Inch Tube.aspx). As I'm using a fake path the name of the URL is not a problem appart from the fact that there is a slash in the name. The URL safe code for it is %2F, and I use a replace to check for this in my SQL query (REPLACE(ProductName, '/','%2F')) AS Link, and before that in the eval statement (NavigateURL='<%# "~/Products/" & Eval("Link").ToString.Replace('/','%2F') %>'). Sadly when databinding this using an eval to a Hyperlink, the %2F changes back to a / (Slash)
Is there a work around for this or should I just not allow for slashes when saving products.
I am not sure if I'm in the right forum but I try anyway.I am making a webproject where I have a database with tables Product, ProductDetails.In my pageLoad event I am retrieving the information from these tabels in two lists: productList and productDetailsList.
Now what I would like to do is to databind these lists in code behind to my ListView. I know how to do this if I only have one list but in my case i have two and in my listView i have fields whose information is in productList list and others in the productDetails list.
Is there a way to achieve this?
Here is some code where I am databinding one List to ListView:
Im a fan of the EF code first and with its last preview of the CTP5 I wonder if it would be safe for me to use this for a smaller site for customer? I would love to get your opinions on this? And any good sources for tutorials and information would be sweet. I'm currently reading the post on scottgu's blog about it.
I have discovered that the NavigateUrl is encoding the URL when it render it. It is a bit of a problem for me in Denmark because we have domianname with special charters. ex. [URL] the hyperlink control render it like [URL]
Have an issue with the HTML editor. Whenever somebody uses an apostophe ( ' ) in the editor and then clicks save (which will send an update to the database) it is taking the apostrophe as part of my command line and it is returning an error. I used a replace to change the apostophe into an encoded html tag but then it was changing it for all the <div> and <span> created by the editor which was causing none of the code to work. how I can encode the apostrophe without encoding the code? Here's my code:
i'm opening a new window and passing on to it variables in a querystring, the values are loaded into a function that is filling my dataset and then filling my Gridview. after i press the button field in my grid to delete an item, the databind doesn't show the updated grid but remains the same. i've noticed that if i navigate back and refresh i see it correctly. in FF btw no problem.
I have a datalist and would like to add an if statement within the Text part of my label.
Tried the following but it doesn't work
Note: if I do a normal eval Text='<%# Eval("UI_successful_trans")%>' the value returned from the database will be 1 or 0. Depending of which value is returned, I would like to have the text "Win" or "Lose" returned. ( I know that this could easily be done in code behind but I would like to know if it is
My web application works if I don't compile it, when I compile, it gives me this nasty error and I am clueless to what I did wrong?
Here is the error: No where in my line 113 has any Eval nor my entire page has any Eval, I used Bind so what is going on? the strange thing is if I leave the page as is with out Publish web site option the same page works perfectly fine.
BC30451: Name 'Eval' is not declared
Line 111: <asp:TemplateField HeaderText="Property Name" SortExpression="PropertyName"> Line 112: <ItemTemplate> Line 113: <asp:Label ID="PropertyNameLabel" runat="server" Text='<%# Bind("PropertyName") %>'></asp:Label>
I have a repeater that has been given a datasource from my database containing pictures. The problem is that when i create and log a user into my site i send him to a folder that has no access from others than the ones with a roles called User. When he creates his profile, he uploads a picture which is saved in the same folder "User/picture/picturename" and in the database "picture/picturename".
Now i need to pull this picture to the Default page page where users are not logged in. If i add an Image Control to the frontpage with ImageUrl='<%#Eval ("PictureThumbURL") %>' it tries to pull out the picture from the folder User which is obvious that it can't since it lacks the User/ in front.
Is it possible to get this picture by manually adding User/ to the ImageUrl='<%#Eval ("PictureThumbURL") %>' and if so, how?
I hava a Gridview connected to an objectDataSource. I only want the gridview to databind when a button is clicked. My problem is that the gridview-ObjectDatasource databinds everytime the page does a postback.
I have written a web mailer that can send and receive emails and display them on a webpage.I have a problem displaying special characters though. Like Russian, and Greek and chinese.I am using openpop.net and I can get the encoding of the incoming email as one of my variables.Thing is, how do I display it? Do I set the content encoding of the whole page to what that specific email encoding is?I've got it UTF-8 at the moment and I get garbage.
I ran into this kind of situation many times without a nice solution. Binding a data source to a gridview and one of the column require nested query. Is it possible to have a callback function other than Eval()?
I have a ListView bound to a database view (vw_Reunions). The Eval statements in the ItemTemplate render the data in vw_Reunions just fine but I have one in the LayoutTemplate that doesn't display. Can anyone tell me why?
I am trying to access column value by using DataBinder.Eval on RowCommand event of Gridview. It always return NOT SET TO ANY INSTANCE error for eveytime. I know how to do this by employing a label control in ItemTemplate, but am trying to find a way to bypass.
Error returned by DataBinder.Eval(row.DataItem, "LinkToInvoice").ToString
I would like to use an eval stmt to return a true/false for the visible property of a HyperLinkField. IF clientComment exists, I would like it to return True, if clientComment is null or "", then would like it to return False.
By default I noticed it already will not show the hyperlink if clientComment is Null, however the bug I'm running into is if the client enters a comment but then later deletes it so it's not null but blank, or "", in which case the HyperLinkField will incorrectly display. Here's my attempt so far but I'm obviously hitting a wall:
Visible='<%# Eval("clientComment")==Null or =="",False) %>'