Server controls in an asp.net repeater

前端 未结 3 791
时光取名叫无心
时光取名叫无心 2021-01-15 09:54

Seems like I\'ve ran into a wall here. I want some datasource to be bound to an asp.net repeater (well, doesn\'t have to be a repeater, but it seems like that\'s what I want

3条回答
  •  死守一世寂寞
    2021-01-15 10:35

    If you don't want to use an ItemCommand and want to just loop through the Repeater's items collection, so you have one "save" button at the bottom of the page, you can do it like this:

    foreach(RepeaterItem itm in MyRepeater.Items)
    {
         TextBox t = (TextBox)(itm.FindControl("TextBox1"));
         // do something with it.
    
    }
    

    Of course, you'll need to make sure that the TextBox1 in the ASPX has the Runat="Server" attribute.

提交回复
热议问题