I am making a website using visual studio (C# ASP.Net) and connecting it with a database I made use sql server
in my database table I have a column for image called (w_image)
I added image link to the rows using this way N'Image/1.jpg'
in the website code I have this code that preview tha database table data in the website page
using System;
using System.Collections;
using System.Text;
public partial class Waqf : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
FillPage();
}
private void FillPage()
{
ArrayList waqfList = ConnectionClass.GetWaqfByType(DropDownList1.SelectedValue);
StringBuilder sb = new StringBuilder();
foreach (Manu manu in waqfList)
{
sb.Append(string.Format(@"<table class='waqfTable'>
<tr>
<th rowspan='7' width='150px'><img runat='server' scr ='{7}' /></th>
<th width ='50px'>ID:</td>
<td>{0}</td>
</tr>
<tr>
<th>Type:</th>
<td>{1}</td>
</tr>
<tr>
<th>Shape:</th>
<td>{2}</td>
</tr>
<tr>
<th>Image Transcription: </th>
<td>{3}</td>
</tr>
<tr>
<th>Waqif Name: </th>
<td>{4}</td>
</tr>
<tr>
<th>Waqf place: </th>
<td>{5}</td>
</tr>
<tr>
<th>Waqf Date: </th>
<td>{6} A.H </td>
</tr>
</table>",
manu.w_id, manu.w_type, manu.w_shape, manu.w_imageTras, manu.waqif_name, manu.w_place, manu.w_date, manu.w_image));
lblOutput.Text = sb.ToString();
}
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
FillPage();
}
}
and this is the connection class code
using System.Collections;
using System.Configuration;
using System.Data.SqlClient;
public static class ConnectionClass
{
private static SqlConnection conn;
private static SqlCommand command;
static ConnectionClass()
{
string connectionString = ConfigurationManager.ConnectionStrings["manuConnection"].ToString();
conn = new SqlConnection(connectionString);
command = new SqlCommand("",conn);
}
public static ArrayList GetWaqfByType(string waqfType)
{
ArrayList list = new ArrayList();
string query = string.Format("SELECT * FROM waqf WHERE w_type LIKE '{0}' ", waqfType);
try
{
conn.Open();
command.CommandText = query;
SqlDataReader reader = command.ExecuteReader();
while (reader.Read())
{
int w_id = reader.GetInt32(0);
string w_type = reader.GetString(1);
string w_shape = reader.GetString(2);
string w_imageTras = reader.GetString(3);
string waqif_name = reader.GetString(4);
string w_place = reader.GetString(5);
int w_date = reader.GetInt32(6);
string w_image = reader.GetString(7);
int m_id = reader.GetInt32(6);
Manu manu = new Manu(w_id, w_type, w_shape, w_imageTras, waqif_name, w_place, w_date, w_image, m_id);
list.Add(manu);
}
}
finally
{
conn.Close();
}
return list;
}
}
this is manu class code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
public class Manu
{
public int w_id { get; set; }
public string w_type { get; set; }
public string w_shape { get; set; }
public string w_imageTras { get; set; }
public string waqif_name { get; set; }
public string w_place { get; set; }
public int w_date { get; set; }
public string w_image { get; set; }
public int m_id { get; set; }
public Manu(int w_id, string w_type, string w_shape, string w_imageTras, string waqif_name, string w_place, int w_date, string w_image, int m_id)
{
this.w_id = w_id;
this.w_type = w_type;
this.w_shape = w_shape;
this.w_imageTras = w_imageTras;
this.waqif_name = waqif_name;
this.w_place = w_place;
this.w_date = w_date;
this.w_image = w_image;
this.m_id = m_id;
}
}
this is the project and as u see all the images ar available in the images folder
finally this is the final result all the information appear except the image it suppose to appear in the left
what shall I do to make the images appear ?
Maybe just a typo in your example but in this line:
'scr' presumably should be 'src'