Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET file filepath
Hello Friends,
I m using File Directory , to bind Data List. I m Displaying My Code here:
 
<asp:DataList ID="dtlist"  RepeatDirection="Horizontal" runat="server" RepeatColumns="4" CellPadding="3">
 <ItemTemplate>
 <asp:Image ID="Image1" ImageUrl='<%# Bind("Name", "~/Images/{0}") %>' runat="server" Height="75px" Width="100px" />                                                                                                      
 <br />
 <asp:HyperLink ID="HyperLink1" Text='<%# Bind("Name") %>' NavigateUrl='<%# Bind("Name", "~/Images/{0}") %>' runat="server"/>
 <br /> 
<asp:LinkButton ID="LinkButton1" runat="server" CommandName="Select" 
 onclick="dtlist_SelectedIndexChanged1" style="text-align: center">Delete</asp:LinkButton>
 </ItemTemplate>
<ItemStyle BorderColor="Brown" BorderStyle="dashed" BorderWidth="3px" HorizontalAlign="Center" VerticalAlign="Bottom" />                           
</asp:DataList>
 
My C# Code Is:
 
 protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BindListView();
        }
    }
    protected void BindListView()
    {
        DirectoryInfo dir = new DirectoryInfo(MapPath("~/Images"));
        FileInfo[] files = dir.GetFiles();
        ArrayList listItems = new ArrayList();
        foreach (FileInfo info in files)
        {
            listItems.Add(info);
        }
        dtlist.DataSource = listItems;
        dtlist.DataBind();
 
    }
 protected void dtlist_SelectedIndexChanged1(object sender, EventArgs e)
    {
        Control c = sender as Control;
  System.Web.UI.WebControls.Image img ((System.Web.UI.WebControls.Image)c.Parent.FindControl("Image1"));
        File.Delete(Server.MapPath(img.ImageUrl.ToString()));
        BindListView();
 
    }
 
The Problem is, as i add images , or upload images, , the page design is increasing.
I want to use paging in my datalist, to arrange in formatted Way,
please help me.
Posted 22-Mar-13 0:51am

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 325
1 DamithSL 265
2 CPallini 235
3 Maciej Los 190
4 Sergey Alexandrovich Kryukov 189
0 OriginalGriff 5,455
1 DamithSL 4,422
2 Maciej Los 3,860
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,010


Advertise | Privacy | Mobile
Web04 | 2.8.141216.1 | Last Updated 22 Mar 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100