Hi Friends.....,
I Need to Change Image in repeater onclick event, for example u may take mail open and close image once after selecting of particular mail the status of mail will get changed to read from unread and image as mail opened from closed i need to do like that Please Let me know any solution for this ASAP
Regards
R.V.Rajagopalan.......,


Upendra Pratap ShahiRank #329 · 7.5K reputationPosted Jul 9, 2015, 9:23 PM EDT
Rahul PrajapatRank #1,209 · 1.5K reputationPosted Jul 6, 2015, 1:57 AM EDT
{
ImageButton ImgBtn = (ImageButton)sender;
string path=((ImageButton)sender).CommandArgument;
if (ImgBtn.ImageUrl == path)
{
ImgBtn.ImageUrl = "Image2_Path";
}
else
{
ImgBtn.ImageUrl = path;
}
}
Upendra Pratap ShahiRank #329 · 7.5K reputationPosted Jul 6, 2015, 3:08 AM EDT
<%@ Page Language="C#" AutoEventWireup="true" EnableEventValidation="true" CodeFile="ChangeImageRepeater.aspx.cs" Inherits="ChangeImageRepeater" %>
DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>title>
head>
<body>
<form id="form1" runat="server">
<div>
<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
<asp:Label ID="Label1" runat="server"><%# Eval("Product_Name")%>asp:Label>
<asp:Label ID="Label2" runat="server"><%# Eval("Quantity")%>asp:Label>
<asp:Label ID="Label3" runat="server"><%# Eval("Price")%>asp:Label>
<asp:ImageButton ID="ImageButton1" runat="server" Height="20px" Width="20px" ImageUrl='<%#Eval("path") %>'
CommandArgument='<%#Eval("path")%>' OnClick="ImageButton1_Click" /><br />
ItemTemplate>
asp:Repeater>
div>
form>
body>
html>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
public partial class ChangeImageRepeater : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindRepeater();
}
}
protected void BindRepeater()
{
DataSet ds = new DataSet();
DataTable dt;
DataRow dr;
DataColumn pName;
DataColumn pQty;
DataColumn pPrice;
DataColumn pPath;
int i = 0;
dt = new DataTable();
pName = new DataColumn("Product_Name", Type.GetType("System.String"));
pQty = new DataColumn("Quantity", Type.GetType("System.Int32"));
pPrice = new DataColumn("Price", Type.GetType("System.Int32"));
pPath = new DataColumn("path", Type.GetType("System.String"));
dt.Columns.Add(pName);
dt.Columns.Add(pQty);
dt.Columns.Add(pPrice);
dt.Columns.Add(pPath);
dr = dt.NewRow();
dr["Product_Name"] = "Product 1";
dr["Quantity"] = 2;
dr["Price"] = 200;
dr["path"] = "Produc1.jpeg";
dt.Rows.Add(dr);
dr = dt.NewRow();
dr["Product_Name"] = "Product 2";
dr["Quantity"] = 5;
dr["Price"] = 480;
dr["path"] = "Produc2.jpeg";
dt.Rows.Add(dr);
dr = dt.NewRow();
dr["Product_Name"] = "Product 3";
dr["Quantity"] = 8;
dr["Price"] = 100;
dr["path"] = "Produc3.jpeg";
dt.Rows.Add(dr);
dr = dt.NewRow();
dr["Product_Name"] = "Product 4";
dr["Quantity"] = 2;
dr["Price"] = 500;
dr["path"] = "Produc4.jpeg";
dt.Rows.Add(dr);
ds.Tables.Add(dt);
Repeater1.DataSource = ds.Tables[0];
Repeater1.DataBind();
}
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
ImageButton ImgBtn = (ImageButton)sender;
string path = ((ImageButton)sender).CommandArgument;
if (ImgBtn.ImageUrl == path)
{
ImgBtn.ImageUrl = "Image2_Path";
ImgBtn.BackColor = System.Drawing.Color.Aqua;
}
else
{
ImgBtn.ImageUrl = path;
ImgBtn.BackColor = System.Drawing.Color.Red;
}
}
}
Rajagopalan R VRank #6,801 · 256 reputationPosted Jul 9, 2015, 9:18 PM EDT
Rajagopalan R VRank #6,801 · 256 reputationPosted Jul 9, 2015, 10:21 PM EDT