Click here to Skip to main content
14,733,890 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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);
        }
    }
}
Posted
v3
Comments
Karthik_Mahalingam 9-May-16 4:28am
   
Post your markup code.
HellHotie 9-May-16 4:48am
   
Posted..
Karthik_Mahalingam 9-May-16 4:54am
   
Always use Reply button, to post Comments/query to the user, else the User wont get notified.
Karthik_Mahalingam 9-May-16 4:55am
   
Please post your entire repeater code,
does your query returns multiple result?
HellHotie 9-May-16 6:31am
   
i am unable to sort out the exact issue yes my query is resulting but just a record
Karthik_Mahalingam 9-May-16 6:49am
   
ok wait. i will come up with a solution.

On the below line debug and check the Rows Count for ds.Tables[0]. If it is greater than 0, then definitely you should see more records.
RepDetails.DataSource = ds;
   
v2
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>
   
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900