0
Answer

barcode showing more times in runtime in asp.net

selvi subramanian

selvi subramanian

9y
473
1
my source
 
<asp:GridView ID="grddata" runat="server" Width="16px"
AutoGenerateColumns="false" onrowdatabound="grddata_RowDataBound"
Height="16px">
<Columns>
<asp:TemplateField ItemStyle-HorizontalAlign="Center" ItemStyle-VerticalAlign="Top">
<ItemTemplate>
<td>
<table cellpadding="2" cellspacing="0" border="1" style="width: 20px; height: 33px; background-color: White" id="Tabl">
<tr align="center">
<td align="center">
<b>Bramandam<u><span>
</span></u></b>
</td></tr>
<tr align="center"><td align="center"><asp:Label ID="sectionname" runat="server" Text='<%#Eval("sectionname") %>'></asp:Label></td></tr>
<tr align="center"><td align="center"><asp:Label ID="lotno" runat="server" Text='<%#Eval("lotno") %>' Visible="false"> </asp:Label><asp:PlaceHolder ID="plBarCode" runat="server" /></td></tr>
<tr align="center"><td align="center"> <asp:Label ID="lotnoo" runat="server" Text='<%#Eval("lotno") %>' Visible="false"></asp:Label></td></tr>
<tr align="center"><td align="center">
<asp:Label ID="rate" runat="server" Text='<%#Eval("rate") %>'></asp:Label></td></tr>
</td>
</table>
</ItemTemplate>
<HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle"></HeaderStyle>
<ItemStyle HorizontalAlign="Center" VerticalAlign="Top" />
</asp:TemplateField>
<asp:TemplateField ItemStyle-HorizontalAlign="Center" ItemStyle-VerticalAlign="Top">
<ItemTemplate>
<td>
<table cellpadding="2" cellspacing="0" border="1" style="width: 20px; height: 33px; background-color: White" id="Tabl">
<tr align="center">
<td align="center">
<b>Bramandam<u><span>
</span></u></b>
</td></tr>
<tr align="center"><td align="center"><asp:Label ID="secionname" runat="server" Text='<%#Eval("sectionname") %>'></asp:Label></td></tr>
<tr align="center"><td align="center"><asp:Label ID="lono" runat="server" Text='<%#Eval("lotno") %>' Visible="false"></asp:Label><asp:PlaceHolder ID="plBarCoode" runat="server" /></td></tr>
<tr align="center"><td align="center"> <asp:Label ID="lonoo" runat="server" Text='<%#Eval("lotno") %>' Visible="false"></asp:Label></td></tr>
<tr align="center"><td align="center">
<asp:Label ID="rae" runat="server" Text='<%#Eval("rate") %>'></asp:Label></td></tr>
</td>
</table>
</ItemTemplate>
<HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle"></HeaderStyle>
<ItemStyle HorizontalAlign="Center" VerticalAlign="Top" />
</asp:TemplateField>
<asp:TemplateField ItemStyle-HorizontalAlign="Center" ItemStyle-VerticalAlign="Top">
<ItemTemplate>
<td>
<table cellpadding="2" cellspacing="0" border="1" style="width: 20px; height: 33px; background-color: White" id="Tabl">
<tr align="center">
<td align="center">
<b>Bramandam<u><span>
</span></u></b>
</td></tr>
<tr align="center"><td align="center"><asp:Label ID="secioname" runat="server" Text='<%#Eval("sectionname") %>'></asp:Label></td></tr>
<tr align="center"><td align="center"><asp:Label ID="loo" runat="server" Text='<%#Eval("lotno") %>' Visible="false"></asp:Label><asp:PlaceHolder ID="plBarCodde" runat="server" /></td></tr>
<tr align="center"><td align="center"> <asp:Label ID="looo" runat="server" Text='<%#Eval("lotno") %>' Visible="false"></asp:Label></td></tr>
<tr align="center"><td align="center">
<asp:Label ID="re" runat="server" Text='<%#Eval("rate") %>'></asp:Label></td></tr>
</td>
</table>
</ItemTemplate>
<HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle"></HeaderStyle>
<ItemStyle HorizontalAlign="Center" VerticalAlign="Top" />
</asp:TemplateField>
<asp:TemplateField ItemStyle-HorizontalAlign="Center" ItemStyle-VerticalAlign="Top">
<ItemTemplate>
<td>
<table cellpadding="2" cellspacing="0" border="1" style="width: 20px; height: 33px; background-color: White" id="Tabl">
<tr align="center">
<td align="center">
<b>Bramandam<u><span>
</span></u></b>
</td></tr>
<tr align="center"><td align="center"><asp:Label ID="secionsname" runat="server" Text='<%#Eval("sectionname") %>'></asp:Label></td></tr>
<tr align="center"><td align="center"><asp:Label ID="losno" runat="server" Text='<%#Eval("lotno") %>' Visible="false"></asp:Label><asp:PlaceHolder ID="plBarCodee" runat="server" /></td></tr>
<tr align="center"><td align="center"> <asp:Label ID="losnoo" runat="server" Text='<%#Eval("lotno") %>' Visible="false"></asp:Label></td></tr>
<tr align="center"><td align="center">
<asp:Label ID="rase" runat="server" Text='<%#Eval("rate") %>'></asp:Label></td></tr>
</td>
</table>
</ItemTemplate>
<HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle"></HeaderStyle>
<ItemStyle HorizontalAlign="Center" VerticalAlign="Top" />
</asp:TemplateField>
<asp:TemplateField ItemStyle-HorizontalAlign="Center" ItemStyle-VerticalAlign="Top">
<ItemTemplate>
<td>
<table cellpadding="2" cellspacing="0" border="1" style="width: 20px; height: 33px;background-color: White" id="Tabl">
<tr align="center">
<td align="center">
<b>Bramandam<u><span>
</span></u></b>
</td></tr>
<tr align="center"><td align="center"><asp:Label ID="seciornname" runat="server" Text='<%#Eval("sectionname") %>'></asp:Label></td></tr>
<tr align="center"><td align="center"><asp:Label ID="lorno" runat="server" Text='<%#Eval("lotno") %> ' Visible="false"></asp:Label><asp:PlaceHolder ID="plBarCCode" runat="server" /></td></tr>
<tr align="center"><td align="center"> <asp:Label ID="lornoo" runat="server" Text='<%#Eval("lotno") %>' Visible="false"></asp:Label></td></tr>
<tr align="center"><td align="center">
<asp:Label ID="rrae" runat="server" Text='<%#Eval("rate") %>'></asp:Label></td></tr>
</td>
</table>
</ItemTemplate>
<HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle"></HeaderStyle>
<ItemStyle HorizontalAlign="Center" VerticalAlign="Top" />
</asp:TemplateField>
</Columns>
</asp:GridView>
 
 
 my code
 
protected void grddata_RowDataBound(object sender, GridViewRowEventArgs e)
{
foreach (GridViewRow gvr in this.grddata.Rows)
{
string barCode = (gvr.FindControl("lotno") as Label).Text;
System.Web.UI.WebControls.Image imgBarCode = new System.Web.UI.WebControls.Image();
using (Bitmap bitMap = new Bitmap(barCode.Length * 40, 80))
{
using (Graphics graphics = Graphics.FromImage(bitMap))
{
Font oFont = new Font("Elfring Bar Code 39 d Hb", 28);
PointF point = new PointF(2f, 2f);
SolidBrush blackBrush = new SolidBrush(Color.Black);
SolidBrush whiteBrush = new SolidBrush(Color.White);
graphics.FillRectangle(whiteBrush, 0, 0, bitMap.Width, bitMap.Height);
graphics.DrawString("*" + barCode + "*", oFont, blackBrush, point);
}
using (MemoryStream ms = new MemoryStream())
{
bitMap.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
byte[] byteImage = ms.ToArray();
Convert.ToBase64String(byteImage);
imgBarCode.ImageUrl = "data:image/png;base64," + Convert.ToBase64String(byteImage);
}
(gvr.FindControl("plBarCode") as PlaceHolder).Controls.Add(imgBarCode);
}
}
foreach (GridViewRow gvr in this.grddata.Rows)
{
string barrCode = (gvr.FindControl("lotno") as Label).Text;
System.Web.UI.WebControls.Image imgBarCoe = new System.Web.UI.WebControls.Image();
using (Bitmap birtMap = new Bitmap(barrCode.Length * 40, 80))
{
using (Graphics grraphics = Graphics.FromImage(birtMap))
{
Font oFonrt = new Font("Elfring Bar Code 39 d Hb", 28);
PointF poinrt = new PointF(2f, 2f);
SolidBrush blackBrrush = new SolidBrush(Color.Black);
SolidBrush whiteBrrush = new SolidBrush(Color.White);
grraphics.FillRectangle(whiteBrrush, 0, 0, birtMap.Width, birtMap.Height);
grraphics.DrawString("*" + barrCode + "*", oFonrt, blackBrrush, poinrt);
}
using (MemoryStream mrs = new MemoryStream())
{
birtMap.Save(mrs, System.Drawing.Imaging.ImageFormat.Png);
byte[] byterImage = mrs.ToArray();
Convert.ToBase64String(byterImage);
imgBarCoe.ImageUrl = "data:image/png;base64," + Convert.ToBase64String(byterImage);
}
(gvr.FindControl("plBarCoode") as PlaceHolder).Controls.Add(imgBarCoe);
}
}
foreach (GridViewRow gvr in this.grddata.Rows)
{
string barrsCode = (gvr.FindControl("lotno") as Label).Text;
System.Web.UI.WebControls.Image igBarCode = new System.Web.UI.WebControls.Image();
using (Bitmap birtsMap = new Bitmap(barrsCode.Length * 40, 80))
{
using (Graphics grraphsics = Graphics.FromImage(birtsMap))
{
Font oFonrst = new Font("Elfring Bar Code 39 d Hb", 28);
PointF poinrst = new PointF(2f, 2f);
SolidBrush blackBrrussh = new SolidBrush(Color.Black);
SolidBrush whiteBrrussh = new SolidBrush(Color.White);
grraphsics.FillRectangle(whiteBrrussh, 0, 0, birtsMap.Width, birtsMap.Height);
grraphsics.DrawString("*" + barrsCode + "*", oFonrst, blackBrrussh, poinrst);
}
using (MemoryStream msrs = new MemoryStream())
{
birtsMap.Save(msrs, System.Drawing.Imaging.ImageFormat.Png);
byte[] bytersImage = msrs.ToArray();
Convert.ToBase64String(bytersImage);
igBarCode.ImageUrl = "data:image/png;base64," + Convert.ToBase64String(bytersImage);
}
(gvr.FindControl("plBarCodde") as PlaceHolder).Controls.Add(igBarCode);
}
}
foreach (GridViewRow gvr in this.grddata.Rows)
{
string barrsCorde = (gvr.FindControl("lotno") as Label).Text;
System.Web.UI.WebControls.Image imBarCode = new System.Web.UI.WebControls.Image();
using (Bitmap birtsrMap = new Bitmap(barrsCorde.Length * 40, 80))
{
using (Graphics grraphsicrs = Graphics.FromImage(birtsrMap))
{
Font oFonrsrt = new Font("Elfring Bar Code 39 d Hb", 28);
PointF poinrsrt = new PointF(2f, 2f);
SolidBrush blackBrrussrh = new SolidBrush(Color.Black);
SolidBrush whiteBrrussrh = new SolidBrush(Color.White);
grraphsicrs.FillRectangle(whiteBrrussrh, 0, 0, birtsrMap.Width, birtsrMap.Height);
grraphsicrs.DrawString("*" + barrsCorde + "*", oFonrsrt, blackBrrussrh, poinrsrt);
}
using (MemoryStream msrsr = new MemoryStream())
{
birtsrMap.Save(msrsr, System.Drawing.Imaging.ImageFormat.Png);
byte[] bytersrImage = msrsr.ToArray();
Convert.ToBase64String(bytersrImage);
imBarCode.ImageUrl = "data:image/png;base64," + Convert.ToBase64String(bytersrImage);
}
(gvr.FindControl("plBarCCode") as PlaceHolder).Controls.Add(imBarCode);
}
}
foreach (GridViewRow gvr in this.grddata.Rows)
{
string baarrsCode = (gvr.FindControl("lotno") as Label).Text;
System.Web.UI.WebControls.Image imgBaCode = new System.Web.UI.WebControls.Image();
using (Bitmap bairtsMap = new Bitmap(baarrsCode.Length * 40, 80))
{
using (Graphics garraphsics = Graphics.FromImage(bairtsMap))
{
Font oaFonrst = new Font("Elfring Bar Code 39 d Hb", 28);
PointF paoinrst = new PointF(2f, 2f);
SolidBrush balackBrrussh = new SolidBrush(Color.Black);
SolidBrush wahiteBrrussh = new SolidBrush(Color.White);
garraphsics.FillRectangle(wahiteBrrussh, 0, 0, bairtsMap.Width, bairtsMap.Height);
garraphsics.DrawString("*" + baarrsCode + "*", oaFonrst, balackBrrussh, paoinrst);
}
using (MemoryStream masrs = new MemoryStream())
{
bairtsMap.Save(masrs, System.Drawing.Imaging.ImageFormat.Png);
byte[] baytersImage = masrs.ToArray();
Convert.ToBase64String(baytersImage);
imgBaCode.ImageUrl = "data:image/png;base64," + Convert.ToBase64String(baytersImage);
}
(gvr.FindControl("plBarCodee") as PlaceHolder).Controls.Add(imgBaCode);
}
}
}
 
 
 
my code
 
 
 

Attachment: brco.rar