Nije ni tebe mrzelo da meni pomognes:)
Baza : id(int),ime(varchar),prezime(varchar),slika(binary or image)
Profil.aspx
...
<form id="form1" runat="server">
<table style="width: 50%;">
<tr>
<td class="style1">
Ime</td>
<td class="style2">
<asp:Label ID="Ime" runat="server"
Text="Label"></asp:Label>
</td>
</tr>
<tr>
<td class="style1">
Prezime</td>
<td class="style2">
<asp:Label ID="Prezime" runat="server"
Text="Label"></asp:Label>
</td>
</tr>
<tr>
<td class="style1">Godiste</td>
<td class="style2">
<asp:Label ID="Godiste" runat="server"
Text="Label"></asp:Label>
</td>
</tr>
<tr height="100" widht="100">
<td class="style1">Slika</td>
<td class="style2" width="100" height="100">
<img id="image_1" src="" runat="server" />
</td>
</tr>
</table>
</form>
...
Profil.aspx.cs
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection(@"---");
conn.Open();
SqlCommand comm = new SqlCommand("select ime,prezime,godiste
from ucenici where id=(@pic)", conn);
comm.Parameters.Add("@pic", id);
DataTable row = new DataTable();
SqlDataAdapter ada = new SqlDataAdapter(comm);
ada.Fill(row);
Ime.Text = row.Rows[0]["ime"].ToString();
Prezime.Text = row.Rows[0]["prezime"].ToString();
Godiste.Text = row.Rows[0]["godiste"].ToString();
image_1.Src = "slika.aspx?id=" + id;
Page.DataBind();
conn.Close();
}
Slika.aspx.cs
protected void Page_Load(object sender, EventArgs e)
{
string ucenikId = Request.QueryString["id"];
string commtext = "select slika from ucenici where id=" +
ucenikId;
SqlConnection sqlconn = new SqlConnection(@"---");
sqlconn.Open();
SqlCommand sqlcomm = new SqlCommand(commtext, sqlconn);
SqlDataReader dr = sqlcomm.ExecuteReader();
if (dr.Read() && (dr["slika"]!=System.DBNull.Value)) //found
image
{
Response.ContentType = "image/jpeg";
Response.BinaryWrite((byte[])dr["slika"]);
}
else
{
FileStream fstream = new FileStream(@"---stavi neku sliku
koja ce ti se prikazati", FileMode.Open);
byte[] buffer = new byte[fstream.Length];
fstream.Read(buffer,0,(int)fstream.Length);
fstream.Close();
Response.BinaryWrite(buffer);
}
sqlconn.Close();
}