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.";

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.

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.