467,864 Members | 1,905 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,864 developers. It's quick & easy.

AJAX Dropdown extender & Gridview

I have a gridview displaying data and would like to use the AJAX dropdown extender so that when the user clicks on a record a dropdown menu will display providing the user with a menu of selections to choose from (yes much like the SharePoint 2007 dropdown menu).

I'm having problems dynamically binding the 'TargetControlID' property of the extender control to the record label in the gridview.

What I'm doing is -

The label's text is the record number for the user to choose from.
AJ_Dropdown is the AJAX Dropdown Extender control

I'm getting a run-time error stating 'The TargetControlID of AJ_DropDown' is not valid. A control with ID 'PIDP3 - #3' could not be found.'

Code called in the ItemDataBound method of the gridview
if (e.Item is GridViewItem)


GridViewItemDataItem = e.Item as GridViewItem;

Label label = (Label)DataItem.FindControl("lblPID");

if (label != null)


label.ID = "PID" + label.Text;

AJ_DropDown.TargetControlID = label.ID; -- Proposal number for current row



Can't figure out what I'm doing wrong.

Any suggestions/ideas?


Bill Youngman

Mar 11 '07 #1
  • viewed: 9408
1 Reply
William Youngman schrieb:
Code called in the ItemDataBound method of the gridview

/if (e.Item is GridViewItem)/


/GridViewItemDataItem = e.Item as GridViewItem;/

/Label label = (Label)DataItem.FindControl("lblPID");/

/if (label != null)/


/label.ID = "PID" + label.Text;/

/AJ_DropDown.TargetControlID = label.ID; --/ Proposal number for current row


Hi Bill,

I'm fairly new to ASP.NET and I might be completely wrong on this, but
why would you set the ID of the label? Shouldn't it be retrieving the
complete ID (which is I think something made up from the gridview ID,
the row ID and the label ID itself and should be stored in the property
ClientID) and assigning that to TargetControlID?

As another approach, try to convert the column with the record label to
a TemplateColumn (if it isn't yet), then you should be able to
declaratively bind the label ID. Here's a snippet of what worked for me:

<ajaxControls:ConfirmButtonExtender ID="cbe" runat="server"
TargetControlID="lbtnDelete" ConfirmText="Really delete?" />
<asp:LinkButton ID="lbtnDelete" runat="server"
CausesValidation="False" CommandName="Delete" Text="Löschen">

(This is assuming that you want the drop down list to be displayed in
the gridview, maybe in an EditItemTemplate instead of the ItemTemplate

Hope this helps,

Mar 12 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by darrel | last post: by
3 posts views Thread by Not Me | last post: by
2 posts views Thread by =?Utf-8?B?c3Jpbml2YXM=?= | last post: by
4 posts views Thread by Peter | last post: by
3 posts views Thread by =?Utf-8?B?Y21lZWsxXzE5OTk=?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.