When creating a website using Asp.Net and using controls such as the ListView is it good practice to use the "Eval" command or should there be a literal and the data populated in the databind event?
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'm having trouble managing how to call upon databind from clicking on a row over an already populated repeater that will populate data regarding the row clicked TO another repeater on the same page.
I've succeeded doing that with postback, calling a jquery click event of that row, taking the data of the specific row and passing it onto a "Querystring" and after postpack, it will be pushed into a Session which the ObjectDataSource of the secondary repeater will recognize and populate the data tables accordingly.
The problem is, I must do it without a postback or in other words purely on client side.
Which method is better (performance-wise) if I have DataBoundControl such as GridView, Repeater, and/or DataList and I use the following method to display data:
Eval("ColumnName") or handling the ItemDataBound or RowDataBound event like: void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e) { // my code to display data here }
I prefer the second one for code readability reason, but for performance reason, are they the same (or are they even the same thing)?
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
My data-binding problem is this: I have a user control that contains a DataList, withing the user control I have an array of objects that are binded to the data list. This works fine and the datalist displays exactly what I want. I have also set up an event that changes the background color of one of the controls on a click. So when the click event happens through a bubble event I change the controls backcolor and then try to call the DataList.DataBind(). This does not work when all the controls Page_Load happens my binded object from the Array is now null. All the examples I have found in code that seem to work have you recreating the data source before calling the DataBind function in the PostBackEvent asp.net step. I don't understand why this is or how I'm suppose to resolve my situation since my datasource in my user control can't easily be recreated. I hope I explained this well I have included a test program that sort of duplicates the issue I'm having. If you run this code you will not get the data list to display at all on a click event. But if you call the BindList function it will work correctly.
I have a listview control on an .aspx page. Inside this list view i want to check "Type" property which comes from database. here is the example code :
[code]...
As a last resort i tried to user DataBinder.Eval() but i get the exception "Expected class, delegate, enum, interface, or struct". What can i be doing wrong? Writing a function in code-behind isn't an option for me.
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.
VS2010 ( Vb.net ).I have a masterpage that contains a gridview, giving stats and information on client files sent to us. This gridview is updated by means of a timer control every 10 seconds. In my grid I have an image field, to display either a tick .. if everything is ok or a cross for any problems.When the timer control timer event forces a gridview databind every 10 seconds.When the page first loads, i get the default red Cross in the gridview imagefield, however when the timer loops forces a 'databind' I lose the redCross and it is replaced with the default image control ( as if no url is set ) . Then I get a server 404 error.I am using the OnDataBound event to fire my vb sub. I have commented out evertything just to get a solid starting point but im still getting errors.
where I show a link if value>0 .. However it gives me a bad url(history.aspx?visitorid=%3C%#%20Eval) when I put visitorID=<%#...%>inside another Eval<%#..%>
What I'm trying to do is if the "Name" column is empty then bind to "Other" column, otherwise bind to "Name" column. Anyone know the right syntax, keep getting object not set to reference. I'm doing this in VB.Net.
if you have two table inner join like SELECT* From A INNER JOIN B on A.ID = B.IDSay A and B tables both have Username values but A's username is Test, and B's username is Test2When I do Eval("Username") it always print out "Test", how can I configure it to print out "Test2"... meaning how to specify which table's value to put using eval.. is there something like Eval(B.("Username"))??
What I am trying to achieve is to use an Eval as parameter in my anchor tag's href. The anchor is nested inside a repeater, why I cannot use the code behind to achieve this.
but an error occurred in the javascript Error Console in Mozilla browser. Error: missing ) after argument list Source File: javascript:NavigateUrl("<%#Eval("TicketID")%>","<%=RedirectURL%20%>"); Line: 1, Column: 22 Source Code: NavigateUrl("<%#Eval("TicketID")%>","<%=RedirectURL %>");
I want to remove the error. but functionality is ok.
and an OnRowDataBound event handler that's tied to the databinding. In that event handler, how do you make column 2 contain 2 objects from TheSource. For instance, in the TheSource, there is a variable for FirstName and another one for LastName. Column 2 needs to contain both the first and last name in the same cell.
I am using ASP Flash Video Player inside a data list control. and i am trying to bind the video url to a column in a SQL Server that has the url. when I use VideoURL='<%# DataBinder.Eval(Container.DataItem,"video") %>'> Nothing happens but when I use VideoURL="/manager/evideos/VTS_01_0_part3.flv" The video plays both have the same url
Dim MyConnection3 As New Data.SqlClient.SqlConnection("Data Source=XXX") Dim mydtadapter3 As New Data.SqlClient.SqlDataAdapter("Select title, video from EVideo", MyConnection3) Dim ds3 As New Data.DataSet mydtadapter3.Fill(ds3, "video") dl.DataSource = ds3.Tables("video").DefaultView dl.DataBind() <ASPNetFlashVideo:FlashVideo ID="FlashVideo1" Width="475" runat="server" VideoURL='<%# DataBinder.Eval(Container.DataItem,"video") %>'> <HTMLAlternativeTemplate> <asp:ImageButton ID="ImageButtonGetFlashPlayer" runat="server" PostBackUrl="http://www.adobe.com/go/getflashplayer" ImageUrl="http://www.aspnetflashvideo.com/images/get_flash_player.gif" /> </HTMLAlternativeTemplate> </ASPNetFlashVideo:FlashVideo>
Code: <asp:Label ID="lblName" runat="server" Text='<%# Eval("Title")%> <%# Eval("Forename")%> <%# Eval("Surname")%>' ></asp:Label> And what is the best way to achive this?
I want to know where lies the difference between these two.I had a google search on this topic and a lots of replies and each of them tell the same thing:
Eval means one way binding(i.e;readonly) Bind means two way binding(i.e;both read as well as write the datasource)
but none of them explained it more clearly.all i want to know is how can i use the Bind to update/insert something from the datasource?