Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net GridView控件_Asp.net_Gridview - Fatal编程技术网

Asp.net GridView控件

Asp.net GridView控件,asp.net,gridview,Asp.net,Gridview,我有一个网格控件。我想从其他控件访问gridview子控件 例: ... ........... ........... 但我有一个错误:“ddeAmirList”的TargetControlID无效。找不到ID为“lblAmirList”的控件 如何从其他控件访问grid view子控件?您必须在GridView控件中放置扩展程序,以便在控件的模板中工作。使用GridView的ondatabound 通过编写以下内容,可以访问gridview中的控件: protected void You

我有一个网格控件。我想从其他控件访问gridview子控件

例:


...
...........
...........
但我有一个错误:“ddeAmirList”的TargetControlID无效。找不到ID为“lblAmirList”的控件


如何从其他控件访问grid view子控件?

您必须在GridView控件中放置扩展程序,以便在控件的模板中工作。

使用GridView的ondatabound

通过编写以下内容,可以访问gridview中的控件:

protected void YourGridView_DataBound(object sender, EventArgs e)
{
    Label label1 = (Label)e.Row.Cells[0].FindControl("lblAmirList");
    // access your control
    label1.Text = "sdfs";

    // do this for other controls inside gridview

}
protected void YourGridView_DataBound(object sender, EventArgs e)
{
    Label label1 = (Label)e.Row.Cells[0].FindControl("lblAmirList");
    // access your control
    label1.Text = "sdfs";

    // do this for other controls inside gridview

}