Reputation: 25
It seem like the code is able to access the control but it return nothing back.
protected void Page_Load(object sender, EventArgs e) {
Literal Literal1 = (Literal)Repeater1.Controls[Repeater1.Controls.Count - 1].FindControl("Literal1");
Response.Write(Literal1.Text);
//this techique is not working for the line below
TextBox TextBox1 = (TextBox)Repeater1.Controls[Repeater1.Controls.Count - 1].FindControl("TextBox1");
Response.Write(TextBox1.Text);
}
public void myRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
//this techique is not working
if (e.Item.ItemType == ListItemType.Footer)
{
TextBox TextBox1 = (TextBox)e.Item.FindControl("TextBox1");
Response.Write(TextBox1.Text);
}
}
Upvotes: 0
Views: 885
Reputation: 25
I have to use "Literal" as an alternate solution by passing the html Textbox problem. I do not like this solution but i guess i have to use it.
Upvotes: 0
Reputation: 8421
I'm not sure what you mean by "they both failed" but if the Text property of the Textbox is empty i might be because you are rebinding your repeater on each post back. Try wrapping your repeater .DataBind() with a !IsPostBack condition.
Upvotes: 1