Getting the ClientID of a control in a GridView EditTemplate

R

Rickey Whitworth

I have a gridview control with an edit template for a field called
ScheduledDate. When the Edit button is clicked on the row, I want to present
the user with a link beside ScheduledDate that pops up a client side
calendar. I can do this easily outside of the Gridview with script similar
to the following:

<a href="#"
onclick="calPopup.select(document.forms[0].elements['<%=txtScheduledDate.ClientID
%>'],'anchorScheduled','MM/dd/yyyy');return false;"id="anchorScheduled">



The main point is that I can reference the client side control using
<%=txtScheduledDate.ClientID%>

How do I do this inside of the edit template. My only thought was to access
it like this.

<%=Gridview1.SelectedRow.FindControl(txtScheduledDate).ClientID %>

But this didn't work. Any suggestions.
 
R

Rickey Whitworth

Found my answer:
Identify the row being edited by using the gridview.EditIndex, then use
FindControl on that row.
<%=gridview1.Rows(gridview1.EditIndex).FindControl("txtCompletedEdit").ClientID
%>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top