Dynamically added control does not postback
I am overriding Grid by adding some client functionality. One of the features is a dropdown box for adjusting the page size. I am expanding the grid with a client server which works great for what I have done so far. Now, however, I'm a bit at a loss to get the dynamically added control to do the postback. There is no Javascript to initiate postbacks.
Protected Overrides Sub OnPreRender(ByVal e As System.EventArgs)
Dim pageSizePanel As New Panel
...
Dim countList As List(Of String) = GetCountList()
Dim pageSizeDropdown As New DropDownList()
pageSizeDropdown.ID = "pageSizeDropdown"
pageSizeDropdown.DataSource = countList
pageSizeDropdown.DataBind()
AddHandler pageSizeDropdown.SelectedIndexChanged, _
AddressOf HandlePageSizeChange
pageSizePanel.Controls.Add(pageSizeDropdown)
...
MyBase.Controls.AddAt(0, pageSizePanel)
MyBase.OnPreRender(e)
End Sub
Html
<select name="tab$grid1Tab$RadGrid1$pageSizeDropdown"
id="tab_grid1Tab_RadGrid1_pageSizeDropdown">
<option selected="selected" value="10">10</option>
<option value="20">20</option>
<option value="40">40</option>
<option value="80">80</option>
<option value="All">All</option>
</select>
So does it have to do with when I "inject" the controls? Does it have to do with adding controls dynamically?
source to share
I think it will be necessary to create a SizeDropdown control page and an event linked earlier in the page lifecycle see http://msdn.microsoft.com/en-us/library/ms178472.aspx . A dynamically added control must be created before the LoadComplete event is loaded in order for its control event to fire.
source to share