On my page i have a Gridview fildet over SQl Auto witout Template Filds.
All setting are code behind. ondatabound
Now i have a Base64 String in the sql table and gridview dont schow image.
i see the base64string in the result.
How i can convert the string to image in code behind
section witout TemplateFilds in aspx. Templatefild is not able Gridview is dinamicel over
multible combination of databases. Just the firs 2 columns are staic.
ASPX
<asp:GridView ID="mergeresult" runat="server" BackColor="LightGoldenrodYellow" BorderColor="Tan" OnRowCreated="mergeresult_OnRowCreated"
OnRowDataBound="mergeresult_OnRowDataBound" BorderWidth="1px" CellPadding="2"
ForeColor="Black" GridLines="Both" autogeneratedcolumns=false>
<AlternatingRowStyle BackColor="PaleGoldenrod" />
<FooterStyle BackColor="Tan" />
<HeaderStyle BackColor="Tan" Font-Bold="True" />
<PagerStyle BackColor="PaleGoldenrod" ForeColor="DarkSlateBlue" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="DarkSlateBlue" ForeColor="GhostWhite" />
<SortedAscendingCellStyle BackColor="#FAFAE7" />
<SortedAscendingHeaderStyle BackColor="#DAC09E" />
<SortedDescendingCellStyle BackColor="#E1DB9C" />
<SortedDescendingHeaderStyle BackColor="#C2A47B" />
<HeaderStyle Font-Size="Small" Font-Underline="true" />
<RowStyle Font-Size="12px" />
</asp:GridView>
C#
protected void mergeresult_OnRowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowIndex >= 0)
{
int totalRow = mergeresult.Rows.Count;
int totalColumns = mergeresult.Columns.Count;
for (int i = 0; i < totalRow + 1; i++)
{
e.Row.Cells[1].HorizontalAlign = HorizontalAlign.Center;
// Image Converting ?? Field e.Row.Cells[1] have the base64 string inside.
}
}
}
}
DataBind
protected void run_Click(object sender, EventArgs e)
{
// Dynamicel results from SQL Databases
mergeresult.DataSource = dt1;
mergeresult.DataBind();
}
2
Answers
Thank you @JobesK for your solution. I have solved my case using the following code:
Do you know how to put the images in Original Format from base64 into a
<span high="75px" width="75px">
Tag with Format resizing.manipulate your SQL so the output is like below, How to display Base64 images in HTML