算了 给你发点代码看看
<asp:DataList ID="DataList1" runat="server" OnItemDataBound="DataList1_ItemDataBound">
<HeaderTemplate><asp:LinkButton ID="LinkButton1" runat="server">LinkButton</asp:LinkButton>
<asp:LinkButton ID="LinkButton2" runat="server">LinkButton</asp:LinkButton></HeaderTemplate>
<ItemTemplate><%#Eval("title")%></ItemTemplate>
<FooterTemplate></FooterTemplate>
</asp:DataList>
这是控件
下面是找Header里面的控件
protected void DataList1_ItemDataBound(object sender, DataListItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Header)
{
Control objControl = e.Item.FindControl("LinkButton1");
if (objControl != null)
{
LinkButton likbtn = (LinkButton)objControl;
//这就是要得到的值了哈
likbtn.Text = "郁闷";
}
Control objControl1 = e.Item.FindControl("LinkButton2");
if (objControl1 != null)
{
LinkButton likbtn = (LinkButton)objControl1;
//这就是要得到的值了哈
likbtn.Text = "试试";
}
}
}
就这样了