I am overriding a Grid, adding some customer features. One of the features is a drop-down to adjust page size. I am extending the grid using a customer server control, which works great for what I’ve done so far. Now, however I am having a bit of trouble getting the dynamically added control to do a postback. The javascript to initiate the postback is not present.
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
The HTML is
<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 this have to do with when I’m ‘injecting’ the controls? Does it have to do with dynamic addition of the controls?
The first thing I noticed was you’d be missing this:
but I’m not sure if that’s all you need for it to work