Accessing Textboxes in Repeater Control

前端 未结 3 885
栀梦
栀梦 2020-12-14 16:58

All the ways I can think to do this seem very hackish. What is the right way to do this, or at least most common?

I am retrieving a set of images from a LINQ-to-SQL

3条回答
  •  不知归路
    2020-12-14 17:29

    .aspx

            
            
                     
            
            
    

    .cs

            foreach (RepeaterItem rptItem in rpt.Items)
            {
                TextBox txtQty = (TextBox)rptItem.FindControl("txtQty");
                if (txtQty != null) { Response.Write(txtQty.Text); }          
            }
    

    Be sure to add EnableViewState="False" to your repeater, otherwise you will get empty string. (That wasted my time, dont waste yours :) )

提交回复
热议问题