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 NayakRank #47 · 31.5K reputationPosted Nov 24, 2011, 6:09 PM EST
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
Kunal Naik163 reputationPosted Nov 24, 2011, 7:13 PM EST
Check out below link,
http://www.c-sharpcorner.com/uploadfile/puranindia/repeater-controls-in-Asp-Net/
Deepak DwijRank #348 · 7.2K reputationPosted Nov 28, 2011, 7:10 AM EST