I'm playing around with a form utilizing a repeater that I've been working on, and I'm currently trying to write an event handler that will get the value of certain controls inside of a repeater after the form containing the repeater has been submitted. I assumed that something similar to this would work if I wanted to retrieve the label from the first repeater item, then set the text of it to the text of another label:
protected void SubmitMessage_Click(object sender, EventArgs e)
{
Label MyLabel = (Label)MyRepeater.Items[0].FindControl("MessageID");
MyLabel2.Text = MyLabel.Text;
}
Using this however, it seems that MyLabel.Text is empty. When testing if MyLabel is null after setting it, the result is false, so I'm trying to figure out any reason why MyLabel wouldn't have the same contents of that in the repeater item that I'm trying to set it to. MyLabel2 is already declared at the top of the class. Thanks in advance.
EDIT: The text of the label in the .aspx file is not being databound inside the text attribute, but rather in the container of the label itself. I'll try the other method on Tuesday morning, as soon as I can get back inside my code, on Benjamin's suggestion.