Hazel Mahmud

Hazel Mahmud

  • 1.4k
  • 315
  • 70.7k

image in itemtemplate disappear when load image handler

Mar 15 2015 12:20 AM
i have below code

. aspx file

<br />
<asp:Label ID="lblnopkj" runat="server" Text="lblnopkj"></asp:Label>
 
  <div>
<asp:GridView ID="gvParentGrid" runat="server" DataKeyNames="nopkj" Width="300"
AutoGenerateColumns="false" OnRowDataBound="gvUserInfo_RowDataBound" GridLines="None" BorderStyle="Solid" BorderWidth="1px"  BorderColor="#df5015">
<HeaderStyle BackColor="#df5015" Font-Bold="true" ForeColor="White" />
<RowStyle BackColor="#E1E1E1" />
<AlternatingRowStyle BackColor="White" />
<HeaderStyle BackColor="#df5015" Font-Bold="true" ForeColor="White" />
<Columns>
<asp:TemplateField ItemStyle-Width="20px">
<ItemTemplate>
<a href="JavaScript:divexpandcollapse('div<%# Eval("nopkj") %>');">
<img alt="" id='imgdiv<%# Eval("nopkj") %>' width="9px" border="0" src="image/plus.gif" />
</a>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="nopkj" HeaderText="NO. PEKERJA"  HeaderStyle-HorizontalAlign="Left" />
<asp:BoundField DataField="nama" HeaderText="NAMA" HeaderStyle-HorizontalAlign="Left" />
<asp:BoundField DataField="jbtn" HeaderText="JABATAN" HeaderStyle-HorizontalAlign="Left" />
<asp:BoundField DataField="jwtn" HeaderText="JAWATAN" HeaderStyle-HorizontalAlign="Left" />
<asp:BoundField DataField="school" HeaderText="PUSAT PENGAJIAN" HeaderStyle-HorizontalAlign="Left" />
<asp:BoundField DataField="tel_samb" HeaderText="NO. SAMBUNGAN" HeaderStyle-HorizontalAlign="Left" />
<asp:BoundField DataField="email" HeaderText="EMAIL" HeaderStyle-HorizontalAlign="Left" /> 
<asp:TemplateField>
<ItemTemplate>
<tr>
<td colspan="100%">
<div id='div<%# Eval("nopkj") %>' style="display: none; position: relative; left: 15px; overflow: auto">
<asp:GridView ID="gvChildGrid" runat="server" AutoGenerateColumns="false" BorderStyle="Double"  BorderColor="#df5015" GridLines="None" Width="250px">
<HeaderStyle BackColor="#df5015" Font-Bold="true" ForeColor="White" />
<RowStyle BackColor="#E1E1E1" />
<AlternatingRowStyle BackColor="White" />
<HeaderStyle BackColor="#df5015" Font-Bold="true" ForeColor="White" />
<Columns>
<asp:BoundField DataField="nopkj" HeaderText="No. Pekerja" HeaderStyle-HorizontalAlign="Left" />
<asp:BoundField DataField="nama" HeaderText="Nama" HeaderStyle-HorizontalAlign="Left" />
  <asp:BoundField DataField="gambar" HeaderText="gambar" HeaderStyle-HorizontalAlign="Left" />
<asp:TemplateField ItemStyle-Width="20px">
<ItemTemplate>
  <asp:Image  ID="imgStaf" runat="server" ImageUrl='<%# "~/Cari/Image_staf.ashx?nopkj_cari="+ Eval("nopkj") %>' Width="120px" height="150px" BorderColor="Black" BorderWidth="2"/>
  <%--<asp:Image  ID="imgStaf" runat="server" Width="120px" height="150px" BorderColor="Black" BorderWidth="2"/>--%>
 
 
</ItemTemplate> 
</asp:TemplateField>

</Columns>
</asp:GridView>
</div>
</td>
</tr>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>


  </div>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
</asp:Content>

aspx.cs code :

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using WebApplication_t630staf;
using session;
using Sybase.Data.AseClient;
using System.Text.RegularExpressions;
using System.Text;
using System.Web.UI.HtmlControls;


namespace session
{
  public partial class WebForm8 : System.Web.UI.Page
  {
  AseDataAdapter da = new AseDataAdapter();

  protected void Page_Load(object sender, EventArgs e)
  {
  if (!IsPostBack)
  {
  }
 
  protected void gvUserInfo_RowDataBound(object sender, GridViewRowEventArgs e)
  {
  using (AseConnection persisConn = ClassConn.GetPersisConnection())
  {
  persisConn.Open();
 
  string Nopkj = e.Row.Cells[1].Text;

  if (e.Row.RowState != DataControlRowState.Edit) // check for RowState
  {
  if (e.Row.RowType == DataControlRowType.DataRow) //check for RowType
  {

  GridView gv = (GridView)e.Row.FindControl("gvChildGrid");
 
  AseCommand cmd = new AseCommand("select nopkj = convert(varchar(8),f630nopkj), nama = f630nama from t630staf where convert(varchar(8),f630nopkj) ='" + Nopkj + "' UNION select nopkj = f620nopkj, nama = f620nama from t620sambilan where UPPER(f620nopkj) ='" + Nopkj + "'", persisConn);
  AseDataAdapter da = new AseDataAdapter(cmd);
  DataSet ds = new DataSet();
  da.Fill(ds);

  gv.DataSource = ds;
  gv.DataBind();
  }
 
  persisConn.Close(); 
  }
  }
  } 
 
  }

my plus.gif image will disappear when the image handler loads. the image are successfully retrieved but the plus.gif image disappear. why is that & how do i solve it.. please help.

Answers (2)