Hello everyone,
i try to bring our local user interface (WPF application) to the web. (Just for local purposes, no access from www, so safety issues are not a big concern atm).
I used asp.net with c# for it, and everything worked fine (mostly gridviews and layout) till i had to do the overview graphic (technical overview of a tunnel).
How do i change the imageurl according to an int value of a specific table in the database? And I need to do it ID related.
Imagecontrol --> Gives a hardcoded ObjectID to --> Codebehind (C#) --> Generates Imageurl for this ID based on the int value of "database row" --> returns imageurl to imagecontrol.
I dont wanna use UniqueID or something
No user interference beside scaling, its just an overview graphic that refreshes every x seconds (i dunno how to do it event based by now e.g. when a record in the database changes).
I have googled a lot, but it is always how to bind a graphic to a gridview or how to show a image from a database.
Help would really be appreciated since i am no real programmer, but i showed some of what i have done to my boss and he liked it and wanted me to do it with the technical overview map aswell, and now i am really stuck and dont get a grip on it.
To make it more clear, there are about 50+ little images on a background image. The background is static, the other 50+ images change from time to time, and can have up to 15 different states.
The values for thes 50 images are stored in a MSSQL 2012 database, and there are ocs-processes that update the database tables.
Database table looks like:
Systime
ID (PrimaryKey)
SollIst
Stellcode
Funktionsbyte
I wanna fetch the data from the database in the code behind like this:
using (SqlCommand command = new SqlCommand("SELECT Id, SollIst ,Funktionsbyte, Stellcode FROM Stellzustand WHERE Id = '" + ID_property_of_image + "' and SollIst = 1 ", connection))
Afterwards i wanna set the url according to the database values:
if funktionsbyte == 1 return ~/images/Stellcode+Funktionsbyte.png
else return ~/images/ID+Black.png
Regards,
Dennis
What I have tried:
Read about 50 different articles to get a grip on it, maybe i am too dumb to see the link between my problem and the read suggestions.
Tried to do it with EVAL, but the image shows nothing, i must have missed sth. and its not an elegant solution it seems.
<pre> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:TrafficCenterConnectionString1 %>" SelectCommand="SELECT Stellzustand.id, Stellzustand.Stellcode, Stellzustand.Funktionsbyte, FROM Stellzustand WHERE SollIst = 1 AND ID = 137496" />
<asp:image id="Image1" runat="server" imageurl='<%# String.Format("~/images/Funktionsbyte={0} & Stellcode={1}", Eval("Funktionsbyte"), Eval("Stellcode" +".png")) %>' />