Hi friends,
I worked with Gridview to show table data in aspx page, but when i was working with repeater it wasnt displaying table data on aspx page, showing table data in repeater is different from showing table data in Gridview ,please explain it will coding as well as from visual studio?
Loading

Satyapriya NayakPosted Nov 24, 2011, 11:09 PM
Try this...
Run the attachments.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page
{
string connStr = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
SqlCommand com;
SqlDataAdapter sqlda ;
DataSet ds;
string str;
protected void Page_Load(object sender, EventArgs e)
{
bindgrid();
bindrepeater();
}
void bindgrid()
{
SqlConnection con = new SqlConnection(connStr);
con.Open();
str = "SELECT * FROM student";
com = new SqlCommand(str, con);
sqlda = new SqlDataAdapter(com);
ds = new DataSet();
sqlda.Fill(ds, "student");
GridView1.DataSource = ds;
GridView1.DataMember = "student";
GridView1.DataBind();
con.Close();
}
void bindrepeater()
{
SqlConnection con = new SqlConnection(connStr);
con.Open();
str = "select * from student";
com = new SqlCommand(str, con);
SqlDataReader reader;
reader = com.ExecuteReader();
Repeater1.DataSource = reader;
Repeater1.DataBind();
reader.Close();
con.Close();
}
}
Thanks
Deepak DwijPosted Nov 28, 2011, 12:10 PM
Kunal NaikPosted Nov 25, 2011, 12:13 AM
Check out below link,
http://www.c-sharpcorner.com/uploadfile/puranindia/repeater-controls-in-Asp-Net/