[ finderetf @ 26.02.2009. 23:43 ] @
Imam stranicu members.aspx (sadrzi osobine clanova i njihove slike koje se dobijaju iz slika.aspx?id=neki_br,repeater),
u kojoj klikom na odredjeni member prosledjujem ID tog clana stranici profil.aspx.
Prosledjivanje vrsim sa profil.aspx?id=neki_broj

U stranici profil.aspx se u odnosu na taj ID ispisuju odredjene vrednosti.
U toj istoj stranici trebam dobiti i sliku, koju mi daje slika.aspx putem gore opisanog postupka.

Kako? Ne znam, jer ne mogu da dohvatim ID iz querystringa u kodu sa HTMLom u formi profile.

[ pl4stik @ 27.02.2009. 09:17 ] @
Pa ako si uspeo da napravish link koji prenosi podatak (ID) ka toj "detail" strani, znaci vidis podatak u address, onda mozes da mu pristupis u code-u npr.

Code:
Request.QueryString["id"]


ili ako koristish neku databind-abilnu kontrolu (detailsview je ono sto tebi treba) tu vec imash definisan QueryString kao source pa ga izberesh ...

Ok?
[ finderetf @ 27.02.2009. 11:16 ] @
Snasao sam se, samo ne koristite Visual Studio Express verzije, pune su
bagova. Npr sve sam lepo odradio ali nije funkcionisalo, sako copy/paste
na prof. verziju i sve lepo radi. Pozdrav
[ deerbeer @ 27.02.2009. 12:35 ] @
WTF ???? Request.QueryString ne radi na Expressu ?
Ajd ako te ne mrzi daj tacno kod da probam da ponovim taj "bug"
[ finderetf @ 27.02.2009. 16:25 ] @
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();
}