Loke Lindhardt Loke Lindhardt - 2 months ago 17
ASP.NET (C#) Question

Simple Append Issue

I have run into to a issue in C#.
I am trying to fill in a ImageUrl in a asp object, and it works fine as shown below.

X = Is the asp:Image tag i target by ID

Y = The Value from my Sql Database, in this case its "products_img_large" the image name.

X.ImageUrl = reader["Y"].ToString();


All of the above work, but what i really want is to, add a path infront of the result of "Y".

Like this:

X.ImageUrl = reader["img/"+"Y"].ToString();


But i can't make it work, and i lack the correct words to google it with relevant results.

Can anyone help or maby point out the error, i be quite happy.

Answer

rewrite as

X.ImageUrl = "img/" + reader["Y"].ToString();