Datalist click Image
I have bind many images in Datalist control now i want to click on any one image from datalist and show in to an asp:image control,in asp.net,please help me how can i do this??
Looking forward for your kind response.
Thx.
Know the answer? Post it. Somebody with the same question will find it here.



ImageUrl='<%# "Admin/"+Eval("simgurl") %>'> |




Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Naresh AvariRank #2,678 · 520 reputationPosted Aug 15, 2012, 2:12 AM EDT
and in Code behind:
Naresh AvariRank #2,678 · 520 reputationPosted Aug 15, 2012, 1:03 AM EDT
Here I am giving one example:
DataList with onItemCommand event and ImageButton with CommandName=imgClick:
Code Behind:
Hope this helps you....
Neha SharmaRank #569 · 4.3K reputationPosted Aug 16, 2012, 2:40 AM EDT
Neha SharmaRank #569 · 4.3K reputationPosted Aug 16, 2012, 2:54 AM EDT
Dorababu MekaRank #457 · 5.5K reputationPosted Aug 16, 2012, 3:35 AM EDT
http://www.aspsnippets.com/Articles/Image-Gallery-using-ASP.Net-DataList-Control-Part-II---Image-Slideshow.aspx
Neha SharmaRank #569 · 4.3K reputationPosted Aug 16, 2012, 3:48 AM EDT
Abhijit baruaRank #3,722 · 397 reputationPosted Aug 16, 2012, 4:34 AM EDT
u download jquery
6 - Resize,zoom popup custom position, fadein, fadeout effects
From
http://www.mind-projects.it/projects/jqzoom/demos.php#demo1
Dorababu MekaRank #457 · 5.5K reputationPosted Aug 16, 2012, 4:56 AM EDT
Neha SharmaRank #569 · 4.3K reputationPosted Aug 16, 2012, 5:05 AM EDT
Dorababu MekaRank #457 · 5.5K reputationPosted Aug 16, 2012, 6:30 AM EDT
Sample Image with desired functionalty
Neha SharmaRank #569 · 4.3K reputationPosted Aug 17, 2012, 3:42 AM EDT
Dorababu MekaRank #457 · 5.5K reputationPosted Aug 17, 2012, 3:46 AM EDT
Insert data in to that as follow in place of Image1
~/Images/1.jpg
~/Images/2.jpg
~/Images/3.jpg
Then create Image folder in your newly created application and add some jpg Images to that folder and rename them with 1,2,3 and then test my code and let me know
Dorababu MekaRank #457 · 5.5K reputationPosted Aug 17, 2012, 3:47 AM EDT
Neha SharmaRank #569 · 4.3K reputationPosted Aug 17, 2012, 3:54 AM EDT
thx for your reply,
\first i need to open and run your application,
but as i open that it says following error,please have a look over this image:
Thx
Dorababu MekaRank #457 · 5.5K reputationPosted Aug 17, 2012, 3:58 AM EDT
In code also
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
GetData();
}
}
public void GetData()
{
MySqlConnection con = new MySqlConnection(ConfigurationManager.ConnectionStrings["sqlcon"].ConnectionString);
MySqlCommand cmd = new MySqlCommand("select * from tblImages", con);
con.Open();
MySqlDataAdapter da = new MySqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
DataList1.DataSource = ds.Tables[0].DefaultView;
DataList1.DataBind();
img.ImageUrl = ds.Tables[0].Rows[0][1].ToString();
}
protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e)
{
if (e.CommandName == "ViewDetails")
{
// Response.Redirect("ViewDetails.aspx?Id=" + e.CommandArgument.ToString());
MySqlConnection con = new MySqlConnection(ConfigurationManager.ConnectionStrings["sqlcon"].ConnectionString);
MySqlCommand cmd = new MySqlCommand("select * from tblImages where Id='" + e.CommandArgument.ToString() + "'", con);
con.Open();
MySqlDataAdapter da = new MySqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
img.ImageUrl = ds.Tables[0].Rows[0][1].ToString();
}
}
As I am having MYSQL database I used Mysql rename them to Sql it you are using SQL.
Check out my video file for the working scenario