Click here to Skip to main content
15,909,645 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want to save image path in database and retrive that images without grid view
Posted
Comments
Prerak Patel 15-Sep-11 1:56am    
Elaborate more.

 
Share this answer
 
Upload can be made with the FileUpload Control...
Give the postedFile a unique name (mabe you can prefix the uploadtime) and save it on disk, then insert FilePath into new row


Instead of GridView you could take a repeater in which you can define its appearance by yourself...
XML
<asp:Repeater runat="server" ID="repImageGallery">
    <ItemTemplate>
        <asp:Image runat="server" ID="img" ImageUrl='<%#Eval("ImageUrl") %>' />
    </ItemTemplate>
</asp:Repeater>


CodeBehind:

C#
repImageGallery.DataSource =  DB.GetImageNames();
repImageGallery.DataBind();



Markus
 
Share this answer
 
try this method to upload!

C#
protected void btnSub_Click(object sender, EventArgs e)
    {
        try
        {
            string filename = FileUpload1.FileName;
            FileUpload1.PostedFile.SaveAs(Server.MapPath("~\\UploadChairoChart\\" + filename));
            string path = "~\\UploadChairoChart\\" + filename;
            SqlConnection con = new SqlConnection(str);
            lblinfo.Text = "";
            lblinfo.Text += " Uploaded Successfully ";
            cmd = new SqlCommand("Insert into tblChart(headline,url) values(@headline,'" + path + "')", con);
            cmd.Parameters.AddWithValue("headline", TextBox5.Text);

            cmd.CommandType = CommandType.Text;
            con.Open();
            cmd.ExecuteNonQuery();
            con.Close();
            uploadDirectory = Path.Combine(Request.PhysicalApplicationPath, "UploadChairoChart");
        }
        catch (Exception ex)
        {
            Response.Write(ex.ToString());
        }
    }

and to retrive use Repeater as MZwahlen suggested
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900