Click here to Skip to main content
15,885,767 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: ASP.net with MYSQL Pin
Piyush Vardhan Singh10-Feb-08 18:50
Piyush Vardhan Singh10-Feb-08 18:50 
GeneralRe: ASP.net with MYSQL Pin
Michael Sync10-Feb-08 19:10
Michael Sync10-Feb-08 19:10 
GeneralRe: ASP.net with MYSQL Pin
Michael Sync10-Feb-08 19:11
Michael Sync10-Feb-08 19:11 
GeneralRe: ASP.net with MYSQL Pin
N a v a n e e t h10-Feb-08 19:46
N a v a n e e t h10-Feb-08 19:46 
QuestionHow to open custom web page when click Browse Button on "File Upload" control Pin
$unil Dhiman10-Feb-08 14:00
$unil Dhiman10-Feb-08 14:00 
GeneralRe: How to open custom web page when click Browse Button on "File Upload" control Pin
Venkatesh Mookkan10-Feb-08 15:45
Venkatesh Mookkan10-Feb-08 15:45 
GeneralRe: How to open custom web page when click Browse Button on "File Upload" control Pin
$unil Dhiman10-Feb-08 20:09
$unil Dhiman10-Feb-08 20:09 
QuestionResponse.BinaryWrite() from within CompositeControl does not work properly Pin
Member 325882310-Feb-08 13:27
Member 325882310-Feb-08 13:27 
Hi,

I have a gridview that generates dynamically inside an aspx page. There is a template field which is also generated dynamically inside the gridview. I need to display Image in this template field. The image data comes from a database as byte[]. I have created a CompositeControl that gets byte[] through a public property and renders this byte[] data as image using HttpContext.Current.Response.BinaryWrite() inside CreateChildControls() method. I am using this composite control in the above template field as a databound control to display image. But when I run the page, the page only displays the image and other page/gridview data is not showing at all. If I see the type of the generated page from the property its "JPEG Image". No "View Souce" is available.

Here I'm giving some extracts from the code:

product.aspx:
=============

TemplateField tc = new TemplateField();
tc.HeaderText = attribute.Name;

//tc.HeaderTemplate = new GridViewTemplateField(ListItemType.Header, attribute.Name);

tc.ItemTemplate = new GridViewTemplateField(ListItemType.Item, "AttribValueId");
tc.HeaderStyle.CssClass = "headerstyle";

tc.ItemStyle.CssClass = "rowstyle";gvProducts.Columns.Add(tc);

GridViewTemplateField.cs:
=========================

void ITemplate.InstantiateIn(System.Web.UI.Control container)
{

switch (templateType)
{

case ListItemType.Item:

ProductImageControl productImgCtl = new ProductImageControl();productImgCtl.DataBinding += new EventHandler(productImgCtrl_DataBinding);
container.Controls.Add(productImgCtl);

break;

}

void productImgCtrl_DataBinding(object sender, EventArgs e)
{

Control control = (Control)sender;
object dataItem = ((IDataItemContainer)control.NamingContainer).DataItem;

DataRowView productRow = (DataRowView)dataItem;
byte[] image = (byte[])productRow["ImageBytes"];

ProductImageControl pi = (ProductImageControl)sender;pi.IsThimbNail = true;
pi.ImgBytes = image;

}

ProductImageControl.cs
=======================
public class ProductImageControl : CompositeControl

{

protected override void CreateChildControls()
{

byte[] image = imgBytes; // through a property
HttpContext.Current.Response.ContentType = mimeType; // through a property

HttpContext.Current.Response.BinaryWrite(image);
}

}

Am I missing something or doing something wrong? Can anyone please give advise?

Thanks in advance!
Generalimport addresses from gmail, yahoo, hotmail, aol, etc. Pin
shefali_sinha10-Feb-08 12:52
shefali_sinha10-Feb-08 12:52 
GeneralRe: import addresses from gmail, yahoo, hotmail, aol, etc. Pin
dilipv12-Feb-08 0:02
dilipv12-Feb-08 0:02 
QuestionRe: import addresses from gmail, yahoo, hotmail, aol, etc. Pin
shefali_sinha13-Feb-08 8:13
shefali_sinha13-Feb-08 8:13 
GeneralRe: import addresses from gmail, yahoo, hotmail, aol, etc. Pin
sukkureddy26-May-08 19:47
sukkureddy26-May-08 19:47 
GeneralApplication of Digital Dictionary Pin
Abdul8510-Feb-08 7:19
Abdul8510-Feb-08 7:19 
GeneralRe: Application of Digital Dictionary Pin
Paul Conrad10-Feb-08 8:10
professionalPaul Conrad10-Feb-08 8:10 
QuestionAJAX updatepanel not preventing entire page postback? Pin
InvalidTypecast10-Feb-08 6:36
InvalidTypecast10-Feb-08 6:36 
AnswerRe: AJAX updatepanel not preventing entire page postback? Pin
InvalidTypecast11-Feb-08 2:40
InvalidTypecast11-Feb-08 2:40 
AnswerRe: AJAX updatepanel not preventing entire page postback? Pin
sukkureddy26-May-08 19:56
sukkureddy26-May-08 19:56 
AnswerRe: AJAX updatepanel not preventing entire page postback? Pin
sukkureddy26-May-08 19:58
sukkureddy26-May-08 19:58 
Generalembedded control Pin
Gareth H10-Feb-08 4:47
Gareth H10-Feb-08 4:47 
GeneralProblem with a nested repeater Pin
simsen10-Feb-08 0:21
simsen10-Feb-08 0:21 
GeneralRe: Problem with a nested repeater Pin
pmarfleet10-Feb-08 7:03
pmarfleet10-Feb-08 7:03 
GeneralRe: Problem with a nested repeater Pin
simsen10-Feb-08 7:48
simsen10-Feb-08 7:48 
GeneralRe: Problem with a nested repeater Pin
pmarfleet10-Feb-08 8:01
pmarfleet10-Feb-08 8:01 
GeneralRe: Problem with a nested repeater Pin
simsen10-Feb-08 8:21
simsen10-Feb-08 8:21 
QuestionCan I access Asp.net Website Adminstrator Tool from the server after deploying my web application? Pin
Nada Adel9-Feb-08 23:19
Nada Adel9-Feb-08 23:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.