Can you recommend a straightforward way or tell me how to fix the workaround?
I want an ObjectDataSource to have a parameter linked to the value of a CheckBox ("chkShowInactivesInGrid") that is inside a CommandItemTemplate.
Is there any way for the ObjectDataSource to refer to this CheckBox? (I get "not found" error.)
As a workaround I use for the parameter a CheckBox "chkShowInactive" that is on the web page, NOT inside a CommandItemTemplate.
<SelectParameters>
<asp:ControlParameter Name="DisplayInactive" ControlID="chkShowInactive" PropertyName="Checked" />
....
<CommandItemTemplate>
<div style="padding: 10px 0px;">
<asp:CheckBox ID="chkShowInactivesInGrid" Text="Show Inactive" runat="server" />
</div>
</CommandItemTemplate>
In this workaround I hope to have the CheckBox inside CommandItemTemplate ("chkShowInactivesInGrid" ) mirror the value of the other checkbox.
I can set the value of "chkShowInactivesInGrid" using the following, BUT this event fires ONLY when the page (actually the user control) is first displayed.
When the page containing the user control is refreshed, the chkShowInactive may have a new value but this value is not transferred to chkShowInactivesInGrid because
the following event is not fired.
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
PopulateOnPrerender = false;
if (e.Item is GridCommandItem)
{
GridCommandItem cmditm = (GridCommandItem)e.Item;
CheckBox cb = (CheckBox)cmditm.FindControl("chkShowInactivesInGrid");
cb.Checked = chkShowInactive.Checked;
}
}