Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

<asp:Label insite <FooterTemplate>

Status
Not open for further replies.

hlybbi

Programmer
Mar 19, 2003
91
IS
i am having problem with <asp:datalist

i am trying to acces an asp:label insite a datalist footertemplate
when i try to SumAll.Text = "test" in my code i get an Object reference not set to an instance of an object ERROR when i try to run the website

can anybody help me

Best regards Hlynur
 
Handle the ItemDataBound event of your DataList.

Check the ItemType of the Item being bound. This will be in e.Item.ItemType.

If the ItemType == ItemType.Footer, use FindControl to get a refernce to the Label.

Then you can set it's properties.

Ex:
Code:
void DataList1_ItemDataBound(object sender, DataListItemEventArgs e){

if(e.Item.ItemType==ListItemType.Footer){

    Control c = e.Item.FindControl("Label1");
    Label l = (Label)c;
    l.Text = "My Text";
}

}



[pipe]
Share your knowledge! -
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top