Get controls ClientID/UniqueID between DetailsView and UpdatePanel
- by robertpnl
Hi guys,
I like to know how to get the ClientID/UniqueID of a control inside a Detailsview controls EditItemTemplate element and when DetailsViews changing to Edit mode and DetailsView is inside a AJAX UpdatePanel. Without UpdatePanel, during PostBack I can get the ClientID's control, but now with an UpdatePanel.
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:DetailsView ID="DetailsView1" runat="server" DataSourceID="SqlDataSource1" AllowPaging="true" AutoGenerateEditButton="true">
<Fields>
<asp:TemplateField>
<EditItemTemplate>
<asp:CheckBox runat="server" ID="chkboxTest" Text="CHECKBOX" />
</EditItemTemplate>
</asp:TemplateField>
</Fields>
</asp:DetailsView>
</ContentTemplate>
</asp:UpdatePanel>
As you see, the EditItemTemplate contains a Checkbox control. So i'm trying to get the ClientID of this checkbox when Detailsview is changing to the Edit mode. I need this value for handling Javascript.
Catching the events ChangingMode/ChangedMode doesn't work; chkbox is null:
void DetailsView1_ModeChanged(object sender, EventArgs e)
{
if (DetailsView1.CurrentMode == DetailsViewMode.Edit)
var chkbox = DetailsView1.Rows[0].FindControl("chkxboxTest"); // <== is null }
Maybe i'm using the wrong event? Someone can give me a tip about this? Thanks.