Veb-foydalanuvchi tekshiruvini repetitorga qanday kiritish mumkin

Stsenariy:

  • UsrControl: custom user control, which contains a textbox and a button, rederend horizontally (in one line).

  • UsrControlContainer: custom user control, which should be able to display multiple UsrControl objects (each object in seperate line, so the Seperator template will probably be
    . This control also contains a button, which adds new UsrControl to the collection.

Mening kodim:



    

    
    

Va:

protected void Button1_Click(object sender, EventArgs e)
{
    rptExample.DataSource = new List {new UsrControl(), new UsrControl()};
    rptExample.DataBind();
}

Oddiy savol - bu ishni bajarish uchun nima qilish kerak ItemTemplate ?

Tartibga solish - Bundan tashqari, uni ko'rsatishdan oldin UsrControl-ga parametrlarni o'tkazishni xohlayman.

0

2 javoblar


     
          
     
     
protected void Button1_Click(object sender, EventArgs e) { rptExample.DataSource = Enumerable.Range(0, 2); rptExample.DataBind(); }
2
qo'shib qo'ydi
Bu ishlayapti, thanks :) Ammo parametrlarni UsrControlga o'tkazishni istasam nima bo'ladi?
qo'shib qo'ydi muallif sventevit, manba

Savolingiz bo'yicha javobni oling. ItemDataBound hodisasida har bir bog'lovchi obyektni qo'lga olishingiz mumkin. Misol uchun, men ishlatganimdek, butun ob'ektni foydalanuvchi tekshirish xususiyati sifatida belgilash.

protected void PersonesRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
    if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
    {
        PersonLine line = (PersonLine)e.Item.FindControl("Person1");
        line.Person = e.Item.DataItem as Osoba;
    }
}

Shak-shubhasiz, voqea ishlovchilarini repetitorga qo'shishingiz kerak:


        
    

1
qo'shib qo'ydi