Display Image based on DropDownList C# ASP
Hello,
So I basically created SQL Server Database and I got it working with displaying my images and drop downlist and everything, however, I want to make it to display an image only if a continent is selected. So if I select Europe, I would like to receive a picture
and short description. Any ideas how can I add the description as well?
So something like:
if(ddlContinents.SelectedValue = "Europe) display image 1"
protected void Page_Load(object sender, EventArgs e)
if (Request.QueryString["ImageID"] != null)
string strQuery = "select Name, ContentType, Data from tblFiles where id=@id";
SqlCommand cmd = new SqlCommand(strQuery);
cmd.Parameters.Add("@id", SqlDbType.Int).Value = Convert.ToInt32(Request.QueryString["ImageID"]);
DataTable dt = GetData(cmd);
if (dt != null)
Byte[] bytes = (Byte[])dt.Rows[0]["Data"];
Response.Buffer = true;
Response.Charset = "";
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.ContentType = dt.Rows[0]["ContentType"].ToString();
Response.AddHeader("content-disposition", "attachment;filename=" + dt.Rows[0]["Name"].ToString());
Response.BinaryWrite(bytes);
Response.Flush();
Response.End();
if (!IsPostBack)
ddlContinents.AppendDataBoundItems = true;
String strConnString = ConfigurationManager
.ConnectionStrings["conString"].ConnectionString;
String strQuery = "select ID, ContinentName from Continents";
SqlConnection con = new SqlConnection(strConnString);
SqlCommand cmd = new SqlCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = strQuery;
cmd.Connection = con;
try
con.Open();
ddlContinents.DataSource = cmd.ExecuteReader();
ddlContinents.DataTextField = "ContinentName";
ddlContinents.DataValueField = "ID";
ddlContinents.DataBind();
catch (Exception ex)
throw ex;
finally
con.Close();
con.Dispose();
private DataTable GetData(SqlCommand cmd)
DataTable dt = new DataTable();
String strConnString = System.Configuration.ConfigurationManager.ConnectionStrings["conString"].ConnectionString;
SqlConnection con = new SqlConnection(strConnString);
SqlDataAdapter sda = new SqlDataAdapter();
cmd.CommandType = CommandType.Text;
cmd.Connection = con;
try
con.Open();
sda.SelectCommand = cmd;
sda.Fill(dt);
return dt;
catch
return null;
finally
con.Close();
sda.Dispose();
con.Dispose();
public void ddlCity_SelectedIndexChanged(object sender, EventArgs e)
lblResults.Text = "You Selected " +
ddlContinents.SelectedItem.Text + " -----> " +
ddlCountry.SelectedItem.Text + " -----> " +
ddlCity.SelectedItem.Text;
public void ddlContinents_SelectedIndexChanged(object sender, EventArgs e)
var continent = ddlContinents.SelectedValue;
ddlCountry.Items.Clear();
ddlCountry.Items.Add(new ListItem("--Select Country--", ""));
ddlCity.Items.Clear();
ddlCity.Items.Add(new ListItem("--Select City--", ""));
ddlCountry.AppendDataBoundItems = true;
String strConnString = ConfigurationManager.ConnectionStrings["conString"].ConnectionString;
String strQuery = "select ID, CountryName from Countries where ContinentID=@ContinentID";
SqlConnection con = new SqlConnection(strConnString);
SqlCommand cmd = new SqlCommand();
cmd.Parameters.AddWithValue("@ContinentID", ddlContinents.SelectedItem.Value);
cmd.CommandType = CommandType.Text;
cmd.CommandText = strQuery;
cmd.Connection = con;
try
con.Open();
ddlCountry.DataSource = cmd.ExecuteReader();
ddlCountry.DataTextField = "CountryName";
ddlCountry.DataValueField = "ID";
ddlCountry.DataBind();
if (ddlCountry.Items.Count > 1)
ddlCountry.Enabled = true;
else
ddlCountry.Enabled = false;
ddlCity.Enabled = false;
catch (Exception ex)
throw ex;
finally
con.Close();
con.Dispose();
<table> <tr> <td align = "center"> <<asp:image ToolTip = "ASP Image Control" ID="Image1" runat="server" ImageUrl ="Default.aspx?ImageID=1" Height="156px" Width="174px"></asp:image></td> <td align = "center"><<asp:image ToolTip = "ASP Image Control" ID="Image2" runat="server" ImageUrl ="Default.aspx?ImageID=2" Height="156px" Width="174px"></asp:image></td> <td align = "center"> <<asp:image ToolTip = "ASP Image Control" ID="Image3" runat="server" ImageUrl ="Default.aspx?ImageID=3" Height="156px" Width="174px"></asp:image></td> </tr> </table>
Questions related to ASP.NET should be posted in the ASP.NET forums (http://forums.asp.net ).
Similar Messages
-
Display image based on conditions.
Hi every one.
We have to display image (circle) based on three conditions.
Example; if employee is < 1000 small circle, if salary is > 1000 and < 10000 medium size circle and >10000 big size circle.
And second condition if employee location is East coast fill black color in that circle, west coast red color central green color.
Third condition is if employee joining date is less than two years I should display * (Star symbol) in that circle.
I am trying to create conditional format but it is possible to display only one image .
My question is how can I change size and color if the image based on conditions and display start symbol with in the image.
I think I have to create different own images to display for every conditions.
Is there any way to create my report?
Thank you very much for your time and help.Hi,
If you want to display everything in one image for end user you need to do some trick.
sal orginal region orginal Joining date Sal decode value Region decode value Joining date decode value ImageCode
100 east 20\2\2008 1 10 100 111
200 WEST 20\2\2008 1 20 100 121
300 NORTH 20\2\2009 1 30 200 211
300 NORTH 20\2\2008 1 30 100 131
100 east 20\2\2008 1 10 100 111
2000 west 20\2\2009 2 20 200 222
30000 south 20\2\2009 3 40 200 243
Create few more columns in your answers, as following
Salary decode value: based on your original salary decode it to 1 or 2 or 3
region decode value: based on your regions decode it to 10 or 20 or 30 or 40
joining date decode value: based on joining date decode it to 100 or 200
Image code add all of decoded values ie 1+10+100 = 111
In report show image based on image code
i.e from above table row1 image code is 111 (small black circle), last record BigCircle Red with Star.
Pain full thing is you need to create 24 images on your own(3(salary range)*4(regions)*2(join dates) =24) and place all 24 conditions in that column.
--Hope it helped you
Thanks
Srinivas Malyala -
Display Images based on site's URL
Hi! I am working on a project and would like a different logo image to appear on the first slide of a captivate course based on the URL of the site. I am wondering if there is a way to do this and what it would involve. Thanks in advance!
So it would look something like this:
/* Convert the web address to lower case for comparisons sake */
var webAddress = window.location.href.toLowerCase();
/* Check if the web address contains part of the URL name */
if(webAddress.indexOf('victortechnologies')>-1){
/* The Web Address contains "victortechnologies' so set the Captivate User Variable to 'Victor' */
window.cpAPIInterface.setVariableValue('vImageToDisplay', 'Victor');
}else{
/* The Web Address does not contain "victortechnologies' so set the Captivate User Variable to 'Thermal' */
window.cpAPIInterface.setVariableValue('vImageToDisplay', 'Thermal');
So you'd use a 2-step Conditional Advanced Action on entry of the first slide to:
Execute this JavaScript (set 1 = 1 for the condition)
Check the value of the vImageToDisplay user variable and show/hide the appropriate image.
Note that you'll want to check if vImageToDisplay is equal to "Victor". I was using "HTML5" in my action below because my images were different.
I tested this and did not run into any timing issues. -
Display image from image path (ASP)
Help needed please. Sorry if the topic has already been
discussed. I did a search but it returned nothing.
My problem.
I can display images on my website by choosing the datasource
and the image path from by database. No issues here. What I want is
to be able to open up a larger image by clicking on this image.
I created another page. On this page is an image placeholder.
The source again is the datasource with the image path to a larger
image. I used a behaviour to open this page however, it shows the
same image (the 1st record in my recordset) whichever image you
click on my origianl page.
Can someone please tell me how to do it? It would be
appreciated.I'm assuming that you are using a repeat region to display
the original
images.
You will need to pass the Primary Key to the new page, and
filter the
recordset on the new page based on that Primary Key.
For example, this would be the link to the new page:
<a
href="page2.asp?ID=<%=(rsImages.Fields.Item("ImageID").Value)%>"
Then on the new page filter the recordset SQL based on the
ImageID,
something like this:
<%
Dim rsImage__MMColParam
rsImage__MMColParam = "1"
If (Request.QueryString("ID") <> "") Then
rsImage__MMColParam = Request.QueryString("ID")
End If
%>
<%
Dim rsImage
Dim rsImage_cmd
Dim rsImage_numRows
Set rsImage_cmd = Server.CreateObject ("ADODB.Command")
rsImage_cmd.ActiveConnection = MM_connImage_STRING
rsImage_cmd.CommandText = "SELECT * FROM tblImages WHERE
ImageID = ?"
rsImage_cmd.Prepared = true
rsImage_cmd.Parameters.Append
rsImage_cmd.CreateParameter("param1", 5,
1, -1, rsImage__MMColParam) ' adDouble
Set rsImage = rsImage_cmd.Execute
rsImage_numRows = 0
%>
Ken Ford
Adobe Community Expert - Dreamweaver
Fordwebs, LLC
http://www.fordwebs.com
"leeweatherill" <[email protected]> wrote in
message
news:ft00gm$spm$[email protected]..
> Help needed please. Sorry if the topic has already been
discussed. I did a
> search but it returned nothing.
>
> My problem.
> I can display images on my website by choosing the
datasource and the
> image
> path from by database. No issues here. What I want is to
be able to open
> up a
> larger image by clicking on this image.
>
> I created another page. On this page is an image
placeholder. The source
> again
> is the datasource with the image path to a larger image.
I used a
> behaviour to
> open this page however, it shows the same image (the 1st
record in my
> recordset) whichever image you click on my origianl
page.
>
> Can someone please tell me how to do it? It would be
appreciated.
> -
hi,
i have a sharepoint custom list with Title and image attachments, now i want to display image attachments in div based on the title.i am using the below code only
SPSite mySite = new SPSite("http://sharepoinsiteaddress");
SPWeb myweb = mySite.OpenWeb();
SPList myList = myweb.Lists["Announcements"];
SPListItem myListItem = myList.GetItemById(1); foreach (String attachmentname in myListItem.Attachments)
String attachmentAbsoluteURL = myListItem.Attachments.UrlPrefix // gets the containing directory URL
+ attachmentname;
// To get the SPSile reference to the attachment just use this code
SPFile attachmentFile = myweb.GetFile(attachmentAbsoluteURL);
// To read the file content simply use this code
Stream stream = attachmentFile.OpenBinaryStream(); StreamReader reader = new StreamReader(stream);
String fileContent = reader.ReadToEnd();
here i am using panel, how can i attach this attached image to panel -
Display Image(which set as behind text) based on some condition.
hi all
I have developed a xml report and in that rtf am displaying a static image (which is set as behin text).
But i need to display the image based on some condition
for example i have a field as ORG_ID
if org_id=87 then image should display for that purpose am planning to use <?if:ORG_ID=87?> condition but where to place this condition for the image.
kindly help me
thanks for all in advance.that too not working because
on image am displaying some other fields.
see i think you didn't get my point.
in my out put page am displaying item details ,quantity,and cost and customer details just like invoice copy .
behind this data am displaying my company logo which will capture whole page size..
if i place the image in table then fields will be automatically in table so i cant restrict image in this way.
Kindly suggest any other way that works only for image which is behind text. i mean condition should be applicable only for image and leaving all other fileds in rtf.
or
help on this how to set a dynamic image as behind the text.
Edited by: maddy on Nov 28, 2012 7:32 AM
Edited by: maddy on Nov 28, 2012 7:35 AM -
Hi !
I have received a set of datas via rs232 and it contains picture messages. I have to decode the datas first and then display them on a canvas.
I have known several functions that may be used . Such as
int SetBitmapData (int bitmapID, int bytesPerRow, int pixelDepth, int colorTable[], unsigned char bits[], unsigned char mask[]);
int CanvasDrawBitmap (int panelHandle, int controlID, int bitmapID, Rect sourceRectangle, Rect destinationRectangle);
However,I don't know how to set the following parameters according to the actual pixel values and color values.
int bytesPerRow, int pixelDepth, int colorTable[], unsigned char bits[], unsigned char mask[]
What's more,I have no idea how to decode the datas.
The attachment is a incomplete project. I will be very appreciated if anyone could help me .
Best regards.
xiepei
I wouldn't care success or failure,for I will only struggle ahead as long as I have been destined to the distance.
Attachments:
Decode and display image.zip 212 KBWell, things are getting a bit clearer now.
1. Your image is actually 240x240 pixel (not 320x240 as you told before). The size of image data is 57600 bytes which corresponds to that frmat (I was puzzled by such a data size compared with larger image dimensions!)
2. The image is a 8-bits-per-pixel one; this means that you must provide a color palette to create the bitmap
3. You cannot simply copy image data into bitmap fields in CVI: CreateBitmap always produce an image with pixeldepth matched with display colour depth (normally 24 or 32 bpp)
All that means that you must:
1. Create the appropriate color palette with 256 colors: it may be a grayscale or color palette depending on camera characteristics. Grayscale palette can be found in my sample project, while sample colour palettes can be found here (here the description of a "standard" 8-bpp color palette)
2. Create the bits array correctly dimensioned for the color depth of your monitor
3. Get each pixel value from the camera, lookup in the color palette for the appropriate colour and create the RGB informations into the bits array in memory
4. Display the bitmap on the canvas
As a first step, I would configure my system for 256-color display setting, create a bitmap and simply copy image data into it: you should be able to get the correct image back to your screen.
Proud to use LW/CVI from 3.1 on.
My contributions to the Developer Zone Community
If I have helped you, why not giving me a kudos? -
Display an image based upon condition A
I am displaying layers based upon windows username. If User B, then Layer B. If Username A, then Layer A. etc. Do you see that is compatible with Acrobat Reader 9? It would appear as if the OCG methods will not work as Reader doesn't support the setIntent OCG object Maybe with another function like backgrounds or watermarks?
The only thing the layer contains is a picture. Can we get the pictures to display using another method other then OCG?
Please advise.You can place a picture as a button icon. You can also show/hide buttons with JavaScript.
George -
How to create a report in Form line Style and can display Image field?
Hi,
In Report builder 10g, I would like to create a Report with Form Line Style and this report included a Image field.
I can choose this Style only when Select Report type is Paper Layout. Because, If I choose Create both Web & Paper Layout or Create Web Layout only then in the next Style tab 03 option Form, Form letter and Mailing Label be Disabled.
But in Paper Layout, my report can not display Image field.
I tried with Web layout and all the other Styles (Except 03 mentioned be Disabled) then all Styles are displayed Imager field OK.
How to create a report in Form line Style and can display Image field?
I was change File Format property of my Image field from text to Image already in Property Inspector. But report only showed MM for my Image field.
Thanks & regards,
BACH
Message was edited by:
bachnpHere you go..Just follow these steps blindly and you are done.
1) Create a year prompt with presentation variable as pv_year
2) Create a report say Mid report with year column selected 3 times
- Put a filter of pv_year presentation variable on first year column with a default value say @{pv_year}{2008}
- Rename the second time column say YEAR+1 and change the fx to CAST(TIME_DIM."YEAR" AS INT)+1
- Rename the second time column say YEAR-1 and change the fx to CAST(TIME_DIM."YEAR" AS INT)-1
Now when you will run Mid Report, this will give you a records with value as 2008 2009 2007
3) Create your main report with criteria as Year and Measure col
- Change the fx for year column as CAST(TIME_DIM."YEAR" AS INT)
- Now put a filter on year column with Filter based on results of another request and select these:
Relationship = greater than or equal to any
Saved Request = Browse Mid Report
Use values in Column = YEAR-1
- Again,put a filter on year column with Filter based on results of another request and select these:
Relationship = less than or equal to any
Saved Request = Browse Mid Report (incase it doesn't allow you to select then select any other request first and then select Mid Report)
Use values in Column = YEAR+1
This will select Year > = 2007 AND Year < = 2009. Hence the results will be for year 2007,2008,2009
This will 100% work...
http://i56.tinypic.com/wqosgw.jpg
Cheers -
Display image in report from BLOB
Hi All,
i have one requirement i.e
i want to display image in a report base on condition
like if id =1 then firest image, id = 2 then second image and id =3 then third image
i have image in database in BOLB type
i need to display in report based on that condition
please help me this requirement is urgent
reg,
jelljust create a query like this:
select id, image_name, image
from tablethen your XML output would be like this:
<ROWSET>
<ROW>
<ID>1</ID>
<IMAGE_NAME>kljkla</IMAGE_NAME>
<IMAGE>Lots of characters that represents the BLOB</IMAGE>
</ROW>
<ROW>
<ID>2</ID>
<IMAGE_NAME>jdkwel</IMAGE_NAME>
<IMAGE>Lots of characters that represents the BLOB</IMAGE>
</ROW>
<ROW>
<ID>3</ID>
<IMAGE_NAME>oled</IMAGE_NAME>
<IMAGE>Lots of characters that represents the BLOB</IMAGE>
</ROW>
<ROW>
<ID>4</ID>
<IMAGE_NAME>mlish</IMAGE_NAME>
<IMAGE>Lots of characters that represents the BLOB</IMAGE>
</ROW>
</ROWSET>in your RTF you put this:
<fo:instream-foreign-object content-type="image/jpg" width="251.8pt" height="174.3pt" xdofo:alt="picture"><xsl:value-of select=".//IMAGE"/></fo:instream-foreign-object>the attributes width and height are optional -
Upload and display image in webside
Hello Friends,
I am developing an auction web site ,and facing some problem so I need your help.
There is some confusion about uploading and displaying images in website .In web based
application if I want to upload images than where have to store the images database or server
side any folder .I have not idea about that please send your ideas and sussesions.
Second problem is What is the best way to display images in webside either giving a direct
path of server side image folder or I need to retrieve all images from database .
I have no idea about it please send me your guideline which are usefull for me to implement in my
website.
what is the correct way to upload and display images in website ?
Thanks . Have a nice day.If you are using a Container you just leave your image files in the home directory of your web application. And forget this idea about database. It´s not necessary in this case.
To display the images just use HTML, <img src="url">. -
Report - Unable to display image stored on External server
Hi
I need to display image on report that is on different instance for that i had put a formula column (in report 10g) and for that coloum i made file format as image and read from file as Yes and giving it the URL of Image stored on different server . but at run time for PDF output i am getting error like REP-1295: Data format of column 'CF_1' is unsupported
Please help me , Thx in advance.
RangaFrom the documentation:
URL Reference
1.Insert a dummy image in your template.
2.In Microsoft Word's Format Picture dialog box select the Web tab. Enter the following syntax in the Alternative text region to reference the image URL:
url:{'http://image location'}
For example, enter: url:{'http://www.oracle.com/images/ora_log.gif'}
Element Reference from XML File
1.Insert a dummy image in your template.
2.In Microsoft Word's Format Picture dialog box select the Web tab. Enter the following syntax in the Alternative text region to reference the image URL:
url:{IMAGE_LOCATION}
where IMAGE_LOCATION is an element from your XML file that holds the full URL to the image.
You can also build a URL based on multiple elements at runtime. Just use the concat function to build the URL string. For example:
url:{concat(SERVER,'/',IMAGE_DIR,'/',IMAGE_FILE)}
where SERVER, IMAGE_DIR, and IMAGE_FILE are element names from your XML file that hold the values to construct the URL.
This method can also be used with the OA_MEDIA reference as follows:
url:{concat('${OA_MEDIA}','/',IMAGE_FILE)}
Edited by: stevencallan on Feb 13, 2009 3:50 PM -
Using flash to display images from sql server or file system
hello,
what methods and parameters of the urlloader class we have to use to display images in a flash player if possible..
also movie should update everytime a new image is added to a database or file
the images can either be in a file system or in a sql database (if possible)
does flash comes with an object of this type or we have to create it.
regards,i responded to your duplicate message 4 days ago:
is it possible to insert and retrieve images from sql server using actionscript.
you'll need server-side script to query your database and you can use the flash urlloader class to call your script.
also is it possible to create a flash scrolling gallery based on images stored in a database and everytime an image is added it is displayed in the gallery.
load the data using the urlloader class and then load the images. periodically query the database for new images if there's no direct way for flash to know a new image was added. -
Insert Image in SharePoint List & Display Image from SharePoint List using C# Pragmatically
hi
i have a share point custom list with the following columns and its types.
Title--------------->Single line of test
FirstName--------------->Single line of test
LastName--------------->Single line of test
Description--------------->multiple line of test
Link--------------->Hyperlink or Picture
Image--------------->Hyperlink or Picture
I've to create a visual web part with the following input fields and which can insert following items in the above list columns
Title asp textbox
First Name asp textbox
Last Name asp textbox
Description asp textbox
Link asp textbox
Image file upload control
Submit asp button
when i click browse button for image control in above web part it browses image .jpg,jpeg or .png file from my computer into image input field above and when i click submit button it must be submitted in the Image column in the above list.
i want to know how can i do that in c# pragmatically.
i've another visual web part which should read the image from the list in Image column and display it in image control on the web part.
like this
<img id="imgdisplay" runat="server" src="" />
how can i read image from image column through c# pragmatically.Hello,
You can't directly add picture into "Hyperlink or Picture" column because this column takes URL value and image is binary etc. You can first upload that picture into picture library (create new picture or document library) then add that image link
into that column.
To add/edit "Hyperlink or Picture" column, SP provided special class called "SPFieldUrl". Wheer you need to pass URL and description as parameter.
Refer this link for you ref:
http://stackoverflow.com/questions/23829576/how-to-decide-sharepoint-url-field-is-set-as-hyperlink-or-picture
Hope it could help
Hemendra:Yesterday is just a memory,Tomorrow we may never see
Please remember to mark the replies as answers if they help and unmark them if they provide no help -
How to display images on my internal isight?
Hi,
I just bought the new iMac 2 gig dual. Running on 10.5.2.
I wanted to know how to display images on my screen during a video conference chat without resorting to holding up a print out to the camera? I need something where I can switch from video mode to image mode and show a single image at a time if I need to. All that while still talking of coarse. If it isn't possible with my iSight software, can you point me to other software I can download and still use my built in cam?
I hope I was clear enough in asking this.
Thanks
LibanWelcome to Apple Discussions, Liban
iChat can do what you want, but I do not know of any web-based video chat site that can.
Look for Help or Support information on the site you are using or ask the Webmaster if his site has the capability to do what you want.
EZ Jim
PowerBook 1.67 GHz w/Mac OS X (10.4.11) G5 DP 1.8 w/Mac OS X (10.5.2) External iSight
Maybe you are looking for
-
Problems with async callback with the BPEL Java API (Urgent- pls help)
Hi, I have an async BPEL process and I invoke it form a JSP page using BPEL java API. I have followed the tutorials and docs at: $SOA_HOME/bpel\samples\tutorials\102.InvokingProcesses\rmi\com\otn\samples\async I can inititiate successfully the proces
-
I can't install iTunes 10.7 without updating MAC OS, not sure which version to install
I just bought the iPhone 5, trying to synch with iTunes to get settings, contacts, photos etc. installed. Got a message that iTunes version 10.7 or later is required. Went to www.itunes.com and downloaded the update, got a message that it requires MA
-
Payment through F-58, but different Account IDs need to assign how?
Hi How to make vendor payment through different Account IDs of the same House Bank? When I am using F-58 T.code for making vendor payment. But only 2 Bank accounts only possible to take. Payment method, Currency, House Bank will be the same but 22 ty
-
I finally got all problems resolved to find another one. I made my router require a WEP to access it wirelessly, and disconnected my laptop from the connection. When I reconnected I come on to find myself greeted with "limited or no connectivity" aft
-
I have a requirement when a purchase order items are being direct shipped to customer it creates an inspection lot that requires qa personnel to close out. I identify process to eliminate inspection lots for DS purchase orders - if(EKPO-PSTYP = 5 - i