无法将所有数据显示到转发器列表中 [英] Unable to display all data into repeater list
本文介绍了无法将所有数据显示到转发器列表中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我有一张表,我希望将数据显示到转发器中,我无法显示所有数据,只能显示第一条记录。请帮我纠正我的代码。
我尝试过:
< asp:Repeater ID = RepDetails runat = server >
< HeaderTemplate >
< span class =code-keyword>< table style = border:1px solid#df5015; width:670p x cellpadding = 0 >
< tr style = background-color:#df5015;白颜色;宽度:670像素; >
< td colspan = 2 >
搜索结果
< / td >
< / tr >
< / HeaderTemplate >
< itemtemplate >
< tr >
< td > ;
联系人:
< asp:Label < span class =code-attribute> ID = LblCntctPrsn runat = server 文字 =' <% #Eval( CONTACTPRSN)%>' / >
< / td >
< / tr >
< tr >
< td >
电子邮件ID:
< < span class =code-leadattribute> asp:Label ID = LblEmail runat = server 文本 =' <% #Eval( EMAILID)%>' / >
< / td >
< / tr >
< tr >
< td >
< table style = background-color:#EBEFF0; border-removed1px dotted#df5015; border-removed1px solid#df50 15;宽度:670px >
< tr >
< td > 发布日期:< asp:Label ID = lblDate runat = server Font-Bold = true / > < / td >
< td > < / td >
< / tr >
< / table >
< / td >
< / tr >
< tr >
& lt; td colspan = 2 > < / td >
< / tr >
< / itemtemplate >
< alternatingitemtemplate >
< tr >
< td >
联系人:
< asp:标签 ID = LblCntctPrsn runat = server 文字 =' <%# Eval( CONTACTPRSN)%>' / >
< / td >
< / tr >
< tr >
< td >
电子邮件ID:
< asp:标签 ID = LblEmail runat = server 文本 =' <% #Eval( EMAILID) %GT;' / >
< / td >
< ; / tr >
< tr >
< td >
< 表 style = background-color:#EBEFF0; border-removed1px dotted#df5015; border-removed1px solid#df5015;宽度:670px >
< tr >
< td > 发布日期:< asp:Label ID = lblDate runat = server Font-Bold = true / > < / td >
< td > < / td >
< / tr >
< / table >
< / td >
< / tr >
< tr >
& lt; td colspan = 2 > < / td >
< / tr >
< / alternatingitemtemplate >
< footertemplate >
< / footertemplate > < / table >
使用系统;
使用 System.Collections.Generic;
使用 System.Linq;
使用 System.Web;
使用 System.Web.UI;
使用 System.Web.UI.WebControls;
使用 System.Configuration;
使用 System.Data.SqlClient;
使用 System.Data;
public partial class _Default:System.Web.UI.Page
{
SqlConnection conn = null ;
SqlCommand cmd = null ;
string con = ConfigurationManager.ConnectionStrings [ Online1\" 跨度>]的ConnectionString。
受保护 void Page_Load( object sender,EventArgs e)
{
try
{
SqlConnection conn = new SqlConnection(con);
SqlCommand chk = new SqlCommand( select CONTACTPRSN,来自EMPLYRSIGNUP的EMAILID,conn);
conn.Open();
DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter(chk);
da.Fill(ds);
RepDetails.DataSource = ds;
RepDetails.DataBind();
}
catch (例外情况)
{
Label1.Text =( 数据加载失败 + ex.Message);
}
}
}
解决方案
在下面的行上调试并检查行计数ds.Tables [0]
。如果它大于0,那么你肯定会看到更多的记录。
RepDetails.DataSource = ds;
< asp :repeater id = RepDetails runat = server >
< HeaderTemplate >
< 表 style = border:1px solid#df5015; width:670px cellpadding = 0 >
< ; tr style < span class =code-keyword> = background-color:#df5015;白颜色;宽度:670像素; >
< td colspan = 2 > 搜索结果
< / td >
< / tr >
< / HeaderTemplate >
< span class =code-keyword>< itemtemplate >
< tr >
< td > 联系人:
< asp:label id = LblCntctPrsn runat = server text = <% #Eval( CONTACTPRSN)%> / >
< / td >
< / tr >
< tr >
< td > 电子邮件ID:
< asp:label id = LblEmail runat = server text = < ;% #Eval( EMAILID)%> < span class =code-attribute> / >
< / td >
< / tr >
< tr >
< td >
< table style = background-color:#EBEFF0;宽度:670px >
< tr >
< td > 发布日期:< asp:label id = lblDate runat = server font-bold = true / > < / td >
< td > < / td >
< / tr >
< / table >
< / td >
< / tr >
< tr >
< td colspan = 2 > < / td >
< / tr >
< / itemtemplate >
< / table > < / asp:repeater >
Hi guys,
I have a table through which i want to display data into repeater, i am unable to display all data but just first record. kindly help me rectify my code.
What I have tried:
<asp:Repeater ID="RepDetails" runat="server" >
<HeaderTemplate>
<table style=" border:1px solid #df5015; width:670px" cellpadding="0">
<tr style="background-color:#df5015; color:White; width:670px;">
<td colspan="2">
Searched Result
</td>
</tr>
</HeaderTemplate>
<itemtemplate>
<tr>
<td>
CONTACT PERSON:
<asp:Label ID="LblCntctPrsn" runat="server" Text='<%#Eval("CONTACTPRSN") %>'/>
</td>
</tr>
<tr>
<td>
EMAIL ID:
<asp:Label ID="LblEmail" runat="server" Text='<%#Eval("EMAILID") %>'/>
</td>
</tr>
<tr>
<td>
<table style="background-color:#EBEFF0;border-removed1px dotted #df5015;border-removed1px solid #df5015; width:670px">
<tr>
<td>Post Date:<asp:Label ID="lblDate" runat="server" Font-Bold="true" /></td>
<td></td>
</tr>
</table>
</td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
</itemtemplate>
<alternatingitemtemplate>
<tr>
<td>
CONTACT PERSON:
<asp:Label ID="LblCntctPrsn" runat="server" Text='<%#Eval("CONTACTPRSN") %>'/>
</td>
</tr>
<tr>
<td>
EMAIL ID:
<asp:Label ID="LblEmail" runat="server" Text='<%#Eval("EMAILID") %>'/>
</td>
</tr>
<tr>
<td>
<table style="background-color:#EBEFF0;border-removed1px dotted #df5015;border-removed1px solid #df5015; width:670px">
<tr>
<td>Post Date:<asp:Label ID="lblDate" runat="server" Font-Bold="true" /></td>
<td></td>
</tr>
</table>
</td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
</alternatingitemtemplate>
<footertemplate>
</footertemplate></table>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Data.SqlClient;
using System.Data;
public partial class _Default : System.Web.UI.Page
{
SqlConnection conn = null;
SqlCommand cmd = null;
string con = ConfigurationManager.ConnectionStrings["Online1"].ConnectionString;
protected void Page_Load(object sender, EventArgs e)
{
try
{
SqlConnection conn = new SqlConnection(con);
SqlCommand chk = new SqlCommand("select CONTACTPRSN,EMAILID from EMPLYRSIGNUP ", conn);
conn.Open();
DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter(chk);
da.Fill(ds);
RepDetails.DataSource = ds;
RepDetails.DataBind();
}
catch (Exception ex)
{
Label1.Text = ("Data Loading Failed" + ex.Message);
}
}
}
解决方案
On the below line debug and check the Rows Count fords.Tables[0]
. If it is greater than 0, then definitely you should see more records.
RepDetails.DataSource = ds;
try this
<asp:repeater id="RepDetails" runat="server" > <HeaderTemplate> <table style="border: 1px solid #df5015; width: 670px" cellpadding="0"> <tr style="background-color: #df5015; color: White; width: 670px;"> <td colspan="2">Searched Result </td> </tr> </HeaderTemplate> <itemtemplate> <tr> <td>CONTACT PERSON: <asp:label id="LblCntctPrsn" runat="server" text="<%#Eval("CONTACTPRSN") %>" /> </td> </tr> <tr> <td>EMAIL ID: <asp:label id="LblEmail" runat="server" text="<%#Eval("EMAILID") %>" /> </td> </tr> <tr> <td> <table style="background-color: #EBEFF0; width: 670px"> <tr> <td>Post Date:<asp:label id="lblDate" runat="server" font-bold="true" /></td> <td></td> </tr> </table> </td> </tr> <tr> <td colspan="2"></td> </tr> </itemtemplate> </table></asp:repeater>
这篇关于无法将所有数据显示到转发器列表中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文