ALL Datalist PROPERTIES AND EVENTS EDITING,DELETING,PAGING
Source part
<asp:DataList ID="dlstImages"
runat="server"
RepeatColumns="4"
RepeatDirection="Horizontal"
Width="100%"
DataKeyField="Image_Gallery_ID"
OnItemCommand="dlstImages_ItemCommand">
<ItemTemplate>
<div id="gallery" style="padding-top: 0 !important; width: 126px !important">
<div id="dlstImg">
<div class="GridHeader"
style="height: 15px !important;">
<asp:Label ID="Label1" runat="server"
Text='<%#
Eval("Image_Gallery_NAME") %>'></asp:Label>
</div>
<div>
<a href="../Uploads/imagegallery/<%#
Eval("Image_Gallery_IMAGE")%>" rel="lightbox[roadtrip]"
title='<%#
Eval("Image_Gallery_NAME") %>'>
<asp:Image ID="imgAlbum"
runat="server"
ImageUrl='<%#
"../Uploads/imagegallery/thum_"+Eval("Image_Gallery_IMAGE")%>'
BorderColor="#50A5DE"
BorderWidth="2px"
BorderStyle="Solid"
Height="100px"
Width="121px"
/></a>
<br />
</div>
<br />
<asp:Label ID="lblId" runat="server"
Text='<%#
bind("Image_Gallery_ID") %>' Visible="False"></asp:Label>
<div style="padding: 0 4px 0 31px;">
<asp:ImageButton ID="Image3" runat="server" ImageUrl="~/admin/images/edit_icon.png" Width="20px"
Height="20px"
ToolTip="Edit"
CommandName="edit"
/>
<asp:ImageButton ID="imgbtnDelete"
runat="server"
CommandName="delete"
Width="20px" Height="20px"
ImageUrl="~/admin/images/delete_icon.png"
OnClientClick='javascript:if(confirm("Do
you wish to delete?")){return true;} return false;' ToolTip="Delete"
/>
</div>
<br />
<br />
</div>
</div>
</ItemTemplate>
<HeaderStyle CssClass="GridHeader" HorizontalAlign="Left"></HeaderStyle>
</asp:DataList>
C # code part
private void Filldatalist(int
id)
{
//bind dtalist by select all images
from database
DataTable
dt = ObjImages.SEL_ALL_Image_GalleryBy_CategoryID(id);
if
(dt.Rows.Count > 0)
{
dlstImages.DataSource = dt;
dlstImages.DataBind();
dlstImages.Visible = true;
}
else
{
idWarning.Visible = true;
dlstImages.Visible = false;
}
}
protected void dlstImages_ItemCommand(object
source, DataListCommandEventArgs e)
{
lblMsg.Visible = false;
if
(e.CommandName == "delete")//seted
on source part
{
Label
lblId = (Label)e.Item.FindControl("lblId");
int
Id = Convert.ToInt32(lblId.Text);
bool
i = ObjImages.DeleteImages(Id);
if
(i == true)
{
lblMsg.Visible = true;
ImgGal.Style["display"] = "null";
Filldatalist(int.Parse(HiddenField1.Value));
}
}
else if (e.CommandName == "edit")//
seted on source part
{
//find value of label using find
control
Label
lblId = (Label)e.Item.FindControl("lblId");
int Id
= Convert.ToInt32(lblId.Text);
FillPhotoDetails(Id);
Filldatalist(int.Parse(HiddenField1.Value));
}
}
Comments
Post a Comment
Thank you for your Comment