i want to change profile picture based on selected image for this i used session for storing all image's id but when i run application it returns me first id only
how to get required id can anybody know how to do this
below is my source code:
<div id="Container">
<div style="float: left; width: 50%">
<table>
<tr>
<td>
<asp:ListView ID="lvPhotoViewer" runat="server" GroupItemCount="1" OnItemDataBound="lvPhotoViewer_ItemDataBound" onitemcommand="lvPhotoViewer_ItemCommand" >
<LayoutTemplate>
<table id="groupPlaceholderContainer" runat="server">
<tr id="groupPlaceholder" runat="server">
</tr>
</table>
</LayoutTemplate>
<ItemTemplate>
<td id="Td4" align="center" style="background-color: #eeeeee;">
<asp:ImageButton runat="server" ID="imPhoto" Height="450px" Width="450px" AlternateText="Imageg not found"/>
</td>
</ItemTemplate>
<GroupTemplate>
<tr id="itemPlaceholderContainer" runat="server">
<td id="itemPlaceholder" runat="server">
</td>
</tr>
</GroupTemplate>
</asp:ListView>
</td>
</tr>
<tr>
<td align="center">
<asp:DataPager ID="DataPager1" runat="server" PagedControlID="lvPhotoViewer" PageSize="1" OnPreRender="DataPager1_PreRender">
<Fields>
<asp:NextPreviousPagerField ButtonType="Link" PreviousPageText="Previous" NextPageText=" Next" />
</Fields>
</asp:DataPager>
</td>
</tr>
</table>
</div>
<div style="float: right; width: 37%">
<asp:Repeater runat="server" ID="RepComment" onitemdatabound="RepComment_ItemDataBound"
onitemcommand="RepComment_ItemCommand" >
<HeaderTemplate>
<table>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<asp:Image runat="server" ID="Image1" CssClass="small_img" />
</td>
<td>
<%# Eval("FirstName") %> <%# Eval("LastName") %></td>
</tr>
<tr>
<td>
<asp:LinkButton ID="lnkbtnSetPic" runat="server" CssClass="Link" Text="Set as profile picture" CommandName="SetasProfilePic"></asp:LinkButton>
</td>
</tr>
<tr>
<td>
<asp:Button ID="btnLike" runat="server" Text="Like" CommandName="Like" CssClass="button" />
<asp:Button ID="btnComment" runat="server" Text="Comment" CommandName="Comment" CssClass="button" />
<asp:Button ID="btnShare" runat="server" Text="Share" CommandName="Share" CssClass="button" />
<asp:Label ID="lblPostDate" runat="server"></asp:Label>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
</div>
</div>
code behind is:
public partial class ViewAlbum : System.Web.UI.Page
{
Images objImages = new Images();
DataSet ds1;
int RegId,PicId;
protected void Page_Load(object sender, EventArgs e)
{
RegId = (Int32)Session["RegId"];
ds1 = objImages.GetAlbum(RegId);
lvPhotoViewer.DataSource = ds1;
lvPhotoViewer.DataBind();
AdminLogin objAdminLogin = new AdminLogin();
RepComment.DataSource = ds.Tables[0];
RepComment.DataBind();
}
protected void DataPager1_PreRender(object sender, EventArgs e)
{
lvPhotoViewer.DataSource = objImages.GetAlbum((Int32)Session["RegId"]);
lvPhotoViewer.DataBind();
}
protected void lvPhotoViewer_ItemDataBound(object sender, ListViewItemEventArgs e)
{
if (e.Item.ItemType == ListViewItemType.DataItem)
{
if (e.Item.FindControl("imPhoto") != null)
{
string imageurl = "Images/user1.png";
ListViewDataItem item = (ListViewDataItem)e.Item;
imageurl = (string)DataBinder.Eval(item.DataItem, "ImageName");
if (item.DataItem != null)
{
imageurl = "Pictures/" + (string)DataBinder.Eval(e.Item.DataItem, "ImageName");
}
((Image)e.Item.FindControl("imPhoto")).ImageUrl = imageurl;
}
}
}
protected void RepComment_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListViewItemType.DataItem)
if(e.Item.ItemType== ListItemType.Item||e.Item.ItemType==ListItemType.AlternatingItem)
{
if (e.Item.FindControl("Image1") != null)
{
string imageurl = "Images/user1.png";
imageurl = "Pictures/" + (string)DataBinder.Eval(e.Item.DataItem, "ImageName");
((Image)e.Item.FindControl("Image1")).ImageUrl = imageurl;
}
}
}
protected void RepComment_ItemCommand(object source, RepeaterCommandEventArgs e)
{
if (e.CommandName == "SetasProfilePic")
{
int picId =(Int32) Session["PicId"];
Images objImages = new Images();
objImages.SetProfilePic(RegId, picId);
}
}
protected void lvPhotoViewer_ItemCommand(object sender, ListViewCommandEventArgs e)
{
if (e.CommandName == "Image")
{
Images objImage = new Images();
Object getPicId = objImage.GetPicId(RegId);
Session["PicId"] = getPicId;
}
}
}