Hi guys,
we have some problems with adding the calendar extender to each text box in a listView (item template contains only one textbox). The problem is with the uniq ID as we thought. When changing the id of the text box and id of calendarextender the calendarextherder is present on runtime but we can't get the values on submit. Please help with this.
Some code below:
TextBox init static int i = 0; protected void AssignFrom_Init(object sender, EventArgs e) { (sender as TextBox).ID = (sender as TextBox).ID + i; (sender as TextBox).EnableViewState = true; (sender as TextBox).ViewStateMode = System.Web.UI.ViewStateMode.Enabled; i++; } Calendar extender init protected void AssignFrom_CalendarExtender_Init(object sender, EventArgs e) { (sender as CalendarExtender).ID = (sender as CalendarExtender).ID + i; (sender as CalendarExtender).TargetControlID = "AssignFrom" + i; } When the item is bound: int index = 0; while (e.Item.Controls[index].ID == null || !e.Item.Controls[index].ID.StartsWith("AssignFrom")) index++; (e.Item.Controls[index] as TextBox).Text = (QSA.AssignFrom != null) ? QSA.AssignFrom.Value.ToShortDateString() : ""; And the getValue function: int index = 0; while (lvdi.Controls[index].ID == null || !lvdi.Controls[index].ID.StartsWith("AssignFrom")) index++; String DateFrom = (lvdi.Controls[index] as TextBox).Text;//(lvdi.FindControl("AssignFrom") as TextBox).Text;