I have a DetailsView that I use to update some database data. In the footer of the DetailsView is a label I am trying to use as a status message panel. For instance, I display validation errors in this label.

After updating a record, which causes a postback, I am unable to get the label to display my status text. For example:

	<div style="padding:4px;">
		<asp:Label ID="FileUploadStatusLabel" runat="server" Text="" Enabled="true" EnableViewState="True"></asp:Label>
File_SqlDataSource.InsertParameters["file_name"].DefaultValue = fileName;
uploadStatusLabel.Text = "Your file was uploaded successfully.";
6 Years
Discussion Span
Last Post by SBA-CDeCinko

The reason the label isn't holding the text could be due to multiple reasons. First, in order to access the label object itself, you cannot simply refer to it by name. This is because it is a child object oh the DetailsView object. To access it properly, you would need to do something similar to this...

Label lbl = (Label)DetailsView.FooterTemplate.FindControl("FileUploadStatusLabel");
lbl.Text = "your status message here";

Next, you will want to do this only AFTER you have called the DataBind method, as calling databind will set the label back to it's original state, i.e. no text.

Edited by CFusion: n/a


I actually tried all of that and never could get it to work while the label was in the footer of the DetailsView. I finally moved the label to below the DetailsView and all works fine.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.