Click here to Skip to main content
12,622,652 members (28,410 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C#2.0 C# ASP.NET
I have tried the following code but it doesn't display data in the repeater control..
protected void Page_Load(object sender, EventArgs e)
{
  if (!IsPostBack)
  {           
    LOADINGREAPETER();
  }
} 
 
public void LOADINGREAPETER()
{
  SqlConnection CN = DBUtil.GetCon();
  if (CN.State != ConnectionState.Closed)
    CN.Close();
  CN.Open();        
  string q = "Select Convert(nVarchar,A.Rec_No) CRec,A.Acc_Name Descr,A.Quantity Qty,Convert(nVarchar,A.Sell_Rate) SRate,Sell_CName Sname , Sell_CCode SCCode, Sell_CValue SCValue ,Convert(float,A.Quantity*A.Sell_Rate*Sell_CValue) as SAmount, A.Service_Tax STax,Convert(nVarchar,(A.Quantity*A.Sell_Rate*Sell_CValue)* A.Service_Tax/100)Tax_Amount,Convert(Float,((A.Quantity*A.Sell_Rate*Sell_CValue)+(A.Quantity*A.Sell_Rate*Sell_CValue)* A.Service_Tax/100)) as Net From eLogs_Invoice_Charges_Details A Where A.Invoice_Code='INV1'";
  SqlDataAdapter da = new SqlDataAdapter(q, CN);
  DataTable dtable = new DataTable();
  da.Fill(dtable);
  Repeater1.DataSource = dtable;
  Repeater1.DataBind();
  CN.Close();
}
Please tell me how to bind data.
Posted 21-Nov-11 1:22am
rajrprk899
Updated 21-Nov-11 1:39am
JF201555K
v2
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

What is your markup code? Then only we can help you. Meanwhile you can refer the link

Click here

You need to define the template for every column.
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

Hi rajrprk, create your .aspx page with, Itemtemplate.like these u can do.
<ASP:Repeater 
    id="rpt1"
     runat="server"
    >
    <HeaderTemplate>
        <table width="100%" style="font: 8pt verdana">
        <tr style="Background-Color:DFECD8">
        <td>First Name</td>

code behind part is ok.
  Permalink  
v2
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 3

hi,
plz check this code

<asp:repeater id="Repeater1" runat="server" xmlns:asp="#unknown">
<headertemplate> EmpNo EName  </headertemplate>
<itemtemplate>
<![CDATA[<%#Eval("EmpNo")%>]]>
<![CDATA[<%#Eval("EName")%>]]> 
</itemtemplate>
<footertemplate> *** End Of Records *** </footertemplate>
</asp:repeater>

Code:

protected void Page_Load(object sender, EventArgs e)
{
sqlconnection cn=new sqlconnection("userid=sa;password=123;database=sample");
sqlDataAdapter da=new sqlDataAdapter("Select * from Emp",cn);
dataset ds=new dataset();
da.fill(ds);
Repeater1.DataSource=ds.Tables[0];
Repeater.DataBind();
}
  Permalink  

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.161128.1 | Last Updated 21 Nov 2011
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100