The image data is served from an another file called WebGridPture.aspx which
accepts the photo Id as a query string (check the src tag of the <img> tag).
So, the code you have written for button will work if is put in a separate
file named webgridpture.aspx (probably in page load).
HTH.
"Raghu Raman" <ra************@rediffmail.com> wrote in message
news:eu**************@TK2MSFTNGP12.phx.gbl...
Hi,
I want to load the images from my sqlserver200 db to the datagrid.I've
seen a code from odetocode.com and it recreated to my wish.
Database : Northwind;Table : from Employees , i want to take only
employeeid,photo to the grid.
html code for Datagrid..
<Columns>
<asp:BoundColumn DataField="employeeid"
HeaderText="EmployeeId"></asp:BoundColumn>
<asp:TemplateColumn HeaderText="Picture">
<ItemTemplate>
<img runat ="server" src ='<%# "WebGridPture.aspx?IDS=" +
DataBinder.Eval(Container.DataItem,"EmployeeId") %> ' ID ="Img1"/>
</ItemTemplate>
</asp:TemplateColumn></Columns>
</asp:datagrid></form>
------------------------------------pageload code------------------
database connection and grid fillings and the grid displays with the
empty images, quite natual since no byte conversion.But in a button a
've the following code to get the image to the grid.
--------------------button code-------------------------------------
string employeeid = Request.QueryString["IDS"].ToString(); //** object
ref not allowed to an instance of an object * error *//
Dr=cmd.ExecuteReader();
Dr.Read();
byte[] bytearray=(byte[]) Dr["photo"];
Response.BinaryWrite(bytearray);
---------------------------------
let us assume that the DBconnection is good.
I am bit confused , how the query string gets the value for all the
records. and where the datasource for the grid ,i also get the errors.
Could u please tell the mistake on these or if u provide a better code ,
it would be great .
Thanks in advance
Raghuraman
*** Sent via Developersdex
http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!