Lets say you have following DataList
<asp:DataList runat="Server" id="DataList1" OnItemCreated="DataList1_ItemCreated">
<ItemTemplate>
<%# Eval("Name") %>
</ItemTemplate>
<FooterTemplate>
<asp:CheckBox ID="chk1" runat="Server" />
</FooterTemplate>
</asp:DataList>
You will have to write following method (This method will fire in ItemCreated event of the DataList) to access the footer control.
protected void DataList1_ItemCreated(object sender, DataListItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Footer)
{
CheckBox chk = (CheckBox)e.Item.FindControl("chk1");
chk.Checked = true;
}
}
Note the e.Item.ItemType == ListItemType.Footer. If you want to work with Header you will have to select Header from ListItemType enumerator.
Regards,
Sheo Narayan, Microsoft MVP
230+ ASP.NET Tips and Tricks - http://www.itfunda.com/Howto
Raju, if this helps please login to Mark As Answer. |
Reply | Alert Moderator