如何查找gridview Header模板的控件 [英] How to find control of gridview Header template

查看:107
本文介绍了如何查找gridview Header模板的控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何找到gridview标题模板的控件点击按钮,这是格外视图控件。

How to find control of gridview Header template on click on button which is out side gridview control.

推荐答案

你的问题不明确,如果可以,它会更好发布你的代码,如果你正在寻找这个,可能会有所帮助

Your question is not clear, its better if you can post your code, in case if you are looking for this, might help
foreach (TableCell headerCell in GridView1.HeaderRow.Cells)
    {
        // or access Controls with index
        //     headerCell.Controls[INDEX]
        Label lblHeader = headerCell.FindControl("headerLabel1") as Label;
                   
    }


试试这个:

Try this:
foreach(GridViewRow gdv in GridView1.Rows){
     if (gdv.RowType == DataControlRowType.Header)
     {
         //Find the control here.
         TextBox txt = (TextBox)gdv.HeaderRow.FindControl("txt");
     }
}









- -Amit





--Amit


在RowDataBound中使用此代码。



Use this code in RowDataBound.

GridViewRow head = grid.HeaderRow;
TextBox Tbx = head.FindControl("txtItem") as TextBox;


这篇关于如何查找gridview Header模板的控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆