我想在转发器内的page_load上找到gridview控件。我怎么能找到它?请尽快回复我。提前致谢。
答案 0 :(得分:2)
使用ItemDataBound访问ITemplate并在那里找到控件。
以下是一个例子:
protected void repeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item ||
e.Item.ItemType == ListItemType.AlternatingItem)
{
var data = e.Item.DataItem;
var index = e.Item.ItemIndex;
var gridView = e.Item.FindControl("gridView1") as GridView;
}
}
答案 1 :(得分:0)
喜欢这个吗?
GridView gv = (GridView) repeater.FindControl("id-of-GridView);
答案 2 :(得分:0)
Repeater_bind()
Dim count As Integer = rep_UnAssignComps.Items.Count
For j = 0 To count - 1
Dim grd As Gridview= Dim rep_DataSimilarToBacthid As GridView = DirectCast(rep_UnAssignComps.Items(i).FindControl("rep_DataSimilarToBacthid"), GridView)
Next