3 Haziran 2017 Cumartesi

GridView islenmemis olan PageIndexChanging olayini etkinlestirdi

Gridview1 GridView islenmemis olan PageIndexChanging olayini etkinlestirdi.


GridView islenmemis olan PageIndexChanging olayini etkinlestirdi.


Merhaba arkadaşlar.Gridview kullanırken yukarıdaki şekilde bir hata alabilirsiniz.Bu hatanın sebebi ;


Gridview bir listelemesi için bir veri gidiyor.Bu veriler bazen gridview içindeki satır sayısından fazla olduğu zaman paging yanı sayfalama yapar.Ancak sayfalama yapabilmesi için PageIndexChanging eventina kod yazmak gerekiyor.Bu var olan index sayfasına geçebilmesi için gerekli koddur.


Eğer gridview ismimiz Gridview1 ise şu şekilde kod yazmak gerekiyor.Gridview propertiesden pageindex eventina cift tiklayarakda bu bölüme gelebilirsiniz.


PageIndex Eventi


protected void Gridview1 _PageIndexChanging(object sender, GridViewPageEventArgs e)


grdGridview1 iste.PageIndex = e.NewPageIndex;

rapordoldur();


Tabi bu kod yazarken gridviewi otomatik doldurucak kodada ihtiyacımız bulunuyor.


Bende rapordoldur fonksiyonu aşağıdaki gibi.Siz kendinize göre gridview doldurma kodunuzu yazabilirsiniz.


 


Rapor Fonkiyonu


public void rapordoldur()


if (DropDownList9.SelectedValue != “”)


if (con.State == System.Data.ConnectionState.Closed)

con.Open();


string language = (string)HttpContext.Current.Session[“Language”];


if (language == “en-US”)


SqlDataAdapter da2 = new SqlDataAdapter();

DataSet ds2 = new DataSet();


da2 = new SqlDataAdapter(@”set dateformat dmy

SELECT p.Id,p2.ProjeAd,t1.ComponentName as Disiplin,t2.ComponentName as komponent,k.ad + ‘ ‘ + k.Soyad as TespitEden,

p.TespitDate,k2.FirmaAd as Sorumlu,t3.ComponentName as issuetype,t4.ComponentName as zone,t5.ComponentName as kat,t6.ComponentName as Bolge,p.Location,p.refdocumentation,p.Aciklamaen as Aciklama , t7.ComponentName as riskcategory,p.bitistarihi,t8.ComponentAd as Statu,

p.dosyayolu

from PunchListv2 p left join ProjeLer p2 on p.ProjeId = p2.Id left join TestComponentleri t1 on p.disiplin =t1.Id

left join TestComponentleri t2 on p.komponent = t2.Id left join Kullanicilar k

on p.TestpitEdenId = k.Id left join Firmalar k2 on p.SorumluId = k2.Id left join TestComponentleri t3 on p.issuetype = t3.Id

left join TestComponentleri t4 on p.Zone= t4.Id left join TestComponentleri t5 on p.Kat= t5.Id left join TestComponentleri t6 on p.Bolge= t6.Id left join TestComponentleri t7 on p.riskcategory= t7.Id left join TestComponentleri t8 on p.SonStatu= t8.Id

where p.ProjeId = ” + Convert.ToInt32(DropDownList9.SelectedValue.ToString()) + ” and p.durum=1 order by t1.ComponentAd”, con);


da2.Fill(ds2);


grdListe.DataSource = ds2;

//ASPxGridView1.KeyFieldName = “Id”;

grdListe.AutoGenerateColumns = false;

grdListe.DataBind();




else


SqlDataAdapter da2 = new SqlDataAdapter();

DataSet ds2 = new DataSet();


da2 = new SqlDataAdapter(@”set dateformat dmy

SELECT p.Id,p2.ProjeAd,t1.ComponentAd as Disiplin,t2.ComponentAd as komponent,k.ad + ‘ ‘ + k.Soyad as TespitEden,

p.TespitDate,k2.FirmaAd as Sorumlu,t3.ComponentAd as issuetype,t4.ComponentAd as zone,t5.ComponentAd as kat,t6.ComponentAd as Bolge,p.Location,p.refdocumentation,p.Aciklamatr as Aciklama , t7.ComponentAd as riskcategory,p.bitistarihi,t8.ComponentName as Statu,

p.dosyayolu

from PunchListv2 p left join ProjeLer p2 on p.ProjeId = p2.Id left join TestComponentleri t1 on p.disiplin =t1.Id

left join TestComponentleri t2 on p.komponent = t2.Id left join Kullanicilar k

on p.TestpitEdenId = k.Id left join Firmalar k2 on p.SorumluId = k2.Id left join TestComponentleri t3 on p.issuetype = t3.Id

left join TestComponentleri t4 on p.Zone= t4.Id left join TestComponentleri t5 on p.Kat= t5.Id left join TestComponentleri t6 on p.Bolge= t6.Id left join TestComponentleri t7 on p.riskcategory= t7.Id left join TestComponentleri t8 on p.SonStatu= t8.Id

where p.ProjeId = ” + Convert.ToInt32(DropDownList9.SelectedValue.ToString()) + ” and p.durum=1 order by t1.ComponentAd”, con);


da2.Fill(ds2);

grdListe.DataSource = ds2;

//ASPxGridView1.KeyFieldName = “Id”;

grdListe.AutoGenerateColumns = false;

grdListe.DataBind();





GridView islenmemis olan PageIndexChanging olayini etkinlestirdi

Hiç yorum yok:

Yorum Gönder