Congratulations to all the winners of April 2013, they have won INR 3400 cash and INR 20147 worth prizes !
DotNetFunda.Com Logo
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 27981 |  Welcome, Guest!   Register  Login
 Home > Forums > ASP.NET > DataList Query ...
Raju

DataList Query

Replies: 1 | Posted by: Raju on 5/1/2008 | Category: ASP.NET Forums | Views: 889 | Status: [Member]  


How to accss footer template (containing some controls) of datalist programmatically in ASP.Net 2.0 ?


Reply | Reply with attachment | Alert Moderator

 Responses below this adGet hundreds of .NET Tips and Tricks videos

 Replies

SheoNarayan
SheoNarayan  
Posted on: 5/1/2008 7:09:59 PM
Level: HonoraryPlatinum | Status: [Microsoft_MVP] [Administrator]

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 

Reply - Please login to reply


Click here to login & reply

About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 5/18/2013 2:41:08 PM