操作GridView嵌套的Repeater控件

来源:互联网 发布:网络词lc是什么意思 编辑:程序博客网 时间:2024/05/19 09:13

protected void gridView_DataBound(object sender, EventArgs e)             

{   

 int index = gv.EditIndex;

                Repeater rpt = (Repeater)gv.Rows[index].Cells[2].FindControl("rpt");
                RepeaterItemCollection cc = rpt.Items;

                for (i = 0; i < cc.Count; i++)
                {
                    for (int j = 0; j < cc[i].Controls.Count;j++)
                    {
                        HyperLink list = cc[i].Controls[j] as HyperLink;
                        if (list != null)
                        {
                            list.Visible = false;
                        }
                        else
                        {
                            TextBox lb = cc[i].Controls[j] as TextBox;
                            if (lb != null)
                            {
                                lb.Visible = true;
                            }
                        }
                    }
                }

 

}

原创粉丝点击