Hello friends,
i have problem in listview display data.
if i am binding data in list view data is dispalyin in corrected formated as i need.
when i am add value from cs into list view label its not displaying into required formate.
add all value is displaying in single td.
i want to seprate it. where is the problem plz advise.
below is list view in which i am facing problem and want to seprate matched record in diffrent td.
if (!IsPostBack)
{
//con.Open();
//string bar = "select Id,MemberShipid from MemberShipDetails where Cancelled=0 order by MemberShipid";
//SqlDataAdapter dabar = new SqlDataAdapter(bar, con);
//DataTable dtbar = new DataTable();
//dabar.Fill(dtbar);
//lsvbarcode.DataSource = dtbar;
//lsvbarcode.DataBind();
//for (int i = 0; i < dtbar.Rows.Count; i++)
//{
// string barCode = dtbar.Rows[i]["MemberShipid"].ToString();
// System.Web.UI.WebControls.Image imgBarCode = new System.Web.UI.WebControls.Image();
// using (Bitmap bitMap = new Bitmap(barCode.Length * 10, 20))
// {
// using (Graphics graphics = Graphics.FromImage(bitMap))
// {
// Font oFont = new Font("IDAutomationHC39M", 10);
// 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);
// }
// ListViewDataItem item = this.lsvbarcode.Items[0];
// Label lblbarcode = item.FindControl("lblbarcode") as Label;
// lblbarcode.Controls.Add(imgBarCode);
<div>
<asp:ListView ID="lsvbarcode" runat="server" ItemPlaceholderID="PlaceHolder" GroupItemCount="2">
<LayoutTemplate>
<ul class="Lstview">
<asp:PlaceHolder ID="PlaceHolder" runat="server"></asp:PlaceHolder>
</ul>
</LayoutTemplate>
<ItemTemplate>
<li>
<table>
<tr>
<td>
Barcode
</td>
<td>
<asp:Label ID="lblbarcode" runat="server"></asp:Label>
</td>
</tr>
</table>
</li>
</ItemTemplate>
</asp:ListView>
</div>
public void AllSlips()
{
con.Open();
string allslips = "select Id,MemberShipid,Name,Address,City,State,Country,Pincode,Mobile1,Phone1 from MemberShipDetails where Cancelled=0 order by MemberShipid";
SqlDataAdapter dallslips = new SqlDataAdapter(allslips, con);
DataTable dtallslips = new DataTable();
dallslips.Fill(dtallslips);
LSVAllSlips.DataSource = dtallslips;
LSVAllSlips.DataBind();
}
<asp:ListView ID="LSVAllSlips" runat="server" GroupItemCount="2" GroupPlaceholderID="groupPlaceholder1"
ItemPlaceholderID="itemPlaceholder1" DataKeyNames="Id" OnPagePropertiesChanged="LSVAllSlips_PagePropertiesChanged">
<LayoutTemplate>
<table style="width: 20cm; border: 1px solid #000;">
<tr id="groupPlaceholder1" runat="server" align="center">
</tr>
</table>
</LayoutTemplate>
<GroupTemplate>
<tr>
<td id="itemPlaceholder1" runat="server">
</td>
</tr>
</GroupTemplate>
<ItemTemplate>
<td style="width: 1cm; padding-top: 20px;">
<div class="textRotate" style="width: 20px"> <asp:Label ID="lblmemid" runat="server" Text='<%# Eval("MemberShipid") %>' Font-Bold="True" Font-Size="Larger" /></div> </td>
<td align="left" style="width: 9.0cm; height: 2.8cm; background: #dedede; border: 1px solid #000;">
<asp:Label ID="lblname" runat="server" Text='<%# Eval("Name") %>' Font-Size="12px"
Font-Bold="true" /><br />
<asp:Label ID="lbladd" runat="server" Text='<%# Eval("Address") %>' Font-Size="12px" /><br />
<asp:Label ID="lblcity" runat="server" Text='<%# Eval("City") %>' Font-Size="12px" />  ,
<asp:Label ID="lblstate" runat="server" Text='<%# Eval("State") %>' Font-Size="12px" />
-
<asp:Label ID="lblpin" runat="server" Text='<%# Eval("Pincode") %>' Font-Size="12px" /><br />
<asp:Label ID="lblcountry" runat="server" Text='<%# Eval("Country") %>' Font-Size="12px" /><br />
<asp:Label ID="lblmo" runat="server" Text='<%# Eval("Mobile1") %>' Font-Size="12px" />    
<asp:Label ID="lblph" runat="server" Text='<%# Eval("Phone1") %>' Font-Size="12px" />
</td>
<%--<td style="width: 1.5cm;">
</td>--%>
</ItemTemplate>
<GroupSeparatorTemplate>
<tr id="Tr1" runat="server">
<td colspan="6" style="height: 0.2cm;">
</td>
</tr>
</GroupSeparatorTemplate>
</asp:ListView>
if i am loading data into lable as above grid record displaying into on single row.if i am binding its displaying correctly. plz help me how to resolve this.