TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
goksu kilic
NA
6
1.3k
multiple repeater
Aug 26 2018 9:08 AM
I have use multiple repeater but I do not want repater1,repeater2,repeater3... because codes are redundant.I have to use different repeaters for retrieve data from the database.
I use 15-20 repeaters on a single page.
How can I do this with less code?
my code:
protected void Page_Load(object sender, EventArgs e)
{
baglanti.Open();
SqlCommand cmd12 = baglanti.CreateCommand();
cmd12.CommandType = CommandType.Text;
cmd12.CommandText = "select * from Menu where DilID = 1";
cmd12.ExecuteNonQuery();
DataTable dt12 = new DataTable();
SqlDataAdapter da12 = new SqlDataAdapter(cmd12);
da12.Fill(dt12);
rptMenu.DataSource = dt12;
rptMenu.DataBind();
baglanti.Close();
baglanti.Open();
SqlCommand cmd3 = baglanti.CreateCommand();
cmd3.CommandType = CommandType.Text;
cmd3.CommandText = "select * from Sehirler where sehirlerID = 1";
cmd3.ExecuteNonQuery();
DataTable dt3 = new DataTable();
SqlDataAdapter da3 = new SqlDataAdapter(cmd3);
da3.Fill(dt3);
rptSehirler.DataSource = dt3;
rptSehirler.DataBind();
baglanti.Close();
baglanti.Open();
SqlCommand cmd13 = baglanti.CreateCommand();
//çekilecek verilerin tipi belirlenir
cmd13.CommandType = CommandType.Text;
//veritabanindan hangi tablolara ve hangi verilere ulasilabilecegi belirlenir.
cmd13.CommandText = "select * from Basliklar where BaslikID = 14 ";
cmd13.ExecuteNonQuery();
//bir data table tablosu yaratilir
DataTable dt13 = new DataTable();
//veritabanindaki tablolar ile köprü kurar.baglantiyi açar,istenilen sorguyu veritabanina sorar,cevabi alir.
SqlDataAdapter da13 = new SqlDataAdapter(cmd13);
//yaratilan tablolara verileri aktarir.
da13.Fill(dt13);
rptMuzeBaslik.DataSource = dt13;
rptMuzeBaslik.DataBind();
baglanti.Close();
baglanti.Open();
SqlCommand cmd14 = baglanti.CreateCommand();
//çekilecek verilerin tipi belirlenir
cmd14.CommandType = CommandType.Text;
//veritabanindan hangi tablolara ve hangi verilere ulasilabilecegi belirlenir.
cmd14.CommandText = "select * from Basliklar where BaslikID = 15";
cmd14.ExecuteNonQuery();
//bir data table tablosu yaratilir
DataTable dt14 = new DataTable();
//veritabanindaki tablolar ile köprü kurar.baglantiyi açar,istenilen sorguyu veritabanina sorar,cevabi alir.
SqlDataAdapter da14 = new SqlDataAdapter(cmd14);
//yaratilan tablolara verileri aktarir.
da14.Fill(dt14);
rptTarihiBaslik.DataSource = dt14;
rptTarihiBaslik.DataBind();
baglanti.Close();
Reply
Answers (
1
)
Application is not calling Global.asax and BundleConfig.cs
Can Anyone Give Real world example of delegate in c#?