Click here to Skip to main content
15,896,154 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
display images in gridveiw in asp.net, images are saved in server folder and image names saved in mysql database
someone help me out pls
Posted
Comments
[no name] 26-Sep-14 16:17pm    
What kind of help do you need? What have you tried already? What was the problem with what you have tried?
Shubh_0009 27-Sep-14 1:39am    
<asp:GridView ID="grdOldAdmission" runat="server" CellPadding="4" ForeColor="#333333" GridLines="None" AllowPaging="True"
Width="100%" OnPageIndexChanging="grdOldAdmission_PageIndexChanging" OnRowCommand="grdOldAdmission_RowCommand">
<alternatingrowstyle backcolor="White">
<columns>
<%--<asp:ButtonField Text="Print Form" CommandName="Print" />--%>
<asp:CheckBoxField />
<asp:TemplateField>
<itemtemplate>
<asp:ImageButton ID="imgEdit" runat="server" CommandArgument="<%#((GridViewRow)Container).RowIndex %>" CommandName="EditRecord" Height="20px" ImageUrl="~/Images/edit1.jpg" OnClientClick="return confirm('Are you sure you want to Edit this Record!')" ToolTip="Edit This Record" Width="20px" />


<asp:TemplateField>
<itemtemplate>
<asp:ImageButton ID="imgView" runat="server" CommandArgument="<%#((GridViewRow)Container).RowIndex %>" CommandName="ViewRecord" Height="20px" ImageUrl="~/Images/view.png" OnClientClick="onView_Click()" ToolTip="View This Record" Width="20px" />


<asp:TemplateField>
<itemtemplate>
<asp:ImageButton ID="imgDelete" runat="server" CommandArgument="<%#((GridViewRow)Container).RowIndex %>" CommandName="DeleteRecord" Height="20px" ImageUrl="~/Images/DeleteIcon.png" OnClientClick="return confirm('Are you sure you want to Delete this Record!')" ToolTip="Delete This Record" Width="20px" />


<asp:TemplateField>
<itemtemplate>
<asp:ImageButton ID="imgPrint" runat="server" CommandArgument="<%#((GridViewRow)Container).RowIndex %>" CommandName="PrintRecord" Height="20px" ImageUrl="~/Images/print.jpg" OnClientClick="return confirm('Are you sure you want to Print this Record!')" ToolTip="Print This Record" Width="20px" />


<asp:TemplateField HeaderText="Image">
<itemtemplate>
<img src='<%= ResolveUrl("~/StdImgName/") %>/<%# Eval("StdImgName") %>' width="100px" height="100px" />



<editrowstyle backcolor="#7C6F57">
<footerstyle backcolor="#1C5E55" font-bold="True" forecolor="White">
<HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" />
<rowstyle backcolor="#E3EAEB">
<rowstyle horizontalalign="Center">
<alternatingrowstyle horizontalalign="Center">
<SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" />
<sortedascendingcellstyle backcolor="#F8FAFA">
<sortedascendingheaderstyle backcolor="#246B61">
<sorteddescendingcellstyle backcolor="#D4DFE1">
<sorteddescendingheaderstyle backcolor="#15524A">


this is my aspx page code
[no name] 27-Sep-14 4:45am    
And.... so?
Shubh_0009 27-Sep-14 4:48am    
Means ... pls be specific . describe what you wanna say
[no name] 27-Sep-14 9:16am    
Means you have not described any kind of a problem or asked a question. Just dumping a bunch of unreadable code here is not a question.

1 solution

Just go through this link

Displaying Images from a Database in a GridView[^]

The code in the above url uses sql server as the database. You will need to make the necessary changes according to your database which is mysql.
 
Share this answer
 
Comments
Shubh_0009 27-Sep-14 1:36am    
Actually the big problem is that I have my images in a folder on server...
And i am saving their name in database.
And i don't want to show the images name on gridview..
ChauhanAjay 27-Sep-14 1:43am    
From the code above you create a folder with name of the student and store his/her image in that folder. Now you will have store the path in the database and use a image field to display them back on the gridview.
Shubh_0009 27-Sep-14 4:49am    
yup.....

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