469,957 Members | 2,683 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

AJAX error with GridView

Hi All,
I'm having a grid view(GridView1) with a hyperlink column.It's ID is Link1
I want to show a popup on hyperlink click.
I'm using ajaxToolkit:ModalPopupExtender for that.
But when i'm using TargetControlID="Link1" for ajaxToolkit:ModalPopupExtender
I'm getting an error

System.InvalidOperationException: The TargetControlID of
'ModalPopupExtender1' is not valid. A control with ID 'Link1' could not be
found.

My ajaxToolkit syntax is

<ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender1" runat="server"
TargetControlID="GridView1"
PopupControlID="Panel1"
BackgroundCssClass="modalBackground"
DropShadow="true"
CancelControlID="CancelButton" />

Thanks in advance

Mar 5 '07 #1
2 5471
the popup extender must be declared in the row/col template, so instead
of a link column, put a link and the extender in the row/column template.

-- bruce (sqlwork.com)

srinivas wrote:
Hi All,
I'm having a grid view(GridView1) with a hyperlink column.It's ID is Link1
I want to show a popup on hyperlink click.
I'm using ajaxToolkit:ModalPopupExtender for that.
But when i'm using TargetControlID="Link1" for ajaxToolkit:ModalPopupExtender
I'm getting an error

System.InvalidOperationException: The TargetControlID of
'ModalPopupExtender1' is not valid. A control with ID 'Link1' could not be
found.

My ajaxToolkit syntax is

<ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender1" runat="server"
TargetControlID="GridView1"
PopupControlID="Panel1"
BackgroundCssClass="modalBackground"
DropShadow="true"
CancelControlID="CancelButton" />

Thanks in advance
Mar 6 '07 #2
hi Bruce
Thanks for the reply.
I tried the way you suggested.But still i'm getting the same error.
System.InvalidOperationException: The TargetControlID of
'ModalPopupExtender1' is not valid. A control with ID 'lnkOrigin' could not
be
found.

Here's the my code

<asp:GridView ID="gvLaneDetails" runat="server" AutoGenerateColumns="False"
Width="90%" AllowSorting=True BorderStyle="Solid" CellPadding="4"
ForeColor="#333333" GridLines="None" BorderColor="White" BorderWidth="1px" >
<Columns >
<asp:TemplateField>
<ItemTemplate>
<a href="javascript:openPopup('NewCity.aspx?LaneID=<% #
DataBinder.Eval(Container.DataItem, "LaneID") %&Type=0')" id='lnkOrigin'
name='lnkOrigin'>Add New</a>

<div>
<asp:Panel ID="Panel1" runat="server" CssClass="modalPopup"
Style="display: none" Width="233px">
<table style="width: 336px; font-family: Tahoma; height:9em"
border="1" bordercolor="black">
<tr style="background-color:#507CD1" >
<td align="center" colspan="3" style="font-size: 9pt;
border-top-style: none; border-right-style: none; border-left-style: none;
border-bottom-style: none; color: white; ">
Enter a City</td>
</tr>
<tr>
<td align="center" colspan="3" style="border-top-style:
none; border-right-style: none; border-left-style: none; border-bottom-style:
none">
<input id="txtCity" type="text" style="width: 236px"
/><br />
<input id="chkAllCities" type="checkbox" /><label
id="lblAll" style="font-family:Tahoma; font-size:small">Apply to all cities
with same error</label></td>
</tr>
<tr>
<td align="center" colspan="3" style="border-top-style:
none; border-right-style: none; border-left-style: none; border-bottom-style:
none" >
<input id="btnAdd" type="button" value="Add"
onclick="win();" style="width: 75px" />
<asp:Button ID="Button1" runat=server />
</td>
</tr>
</table>

<div align="center">
<asp:Button ID="OkButton" runat="server" Text="OK" />
<asp:Button ID="CancelButton" runat="server" Text="Cancel" />
</div>
</asp:Panel>
<br />

<ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender1" runat="server"
TargetControlID="lnkOrigin"
PopupControlID="Panel1"
BackgroundCssClass="modalBackground"
DropShadow="true"
CancelControlID="CancelButton" />

</div>

</ItemTemplate>
<ItemStyle Width="50px" BorderStyle="None" />
<HeaderStyle BorderColor="White" BorderStyle="None" />
</asp:TemplateField>
</Columns>
<AlternatingRowStyle BackColor="White" BorderStyle="Solid"
Wrap="True" BorderColor="White" BorderWidth="1px" />
<HeaderStyle BackColor="#507CD1" BorderColor="White"
BorderStyle="Solid" BorderWidth="2px" Height=10px Font-Bold="True"
ForeColor="White" HorizontalAlign="Center" />
<RowStyle height="10px" BackColor="#EFF3FB" BorderColor="White"
BorderStyle="Solid" BorderWidth="1px" />

<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True"
ForeColor="#333333" />
<FooterStyle BackColor="#507CD1" Font-Bold="True"
ForeColor="White" />
<EditRowStyle BackColor="#2461BF" />
<PagerStyle BackColor="#2461BF" ForeColor="White"
HorizontalAlign="Center" />
</asp:GridView>

Thanks
Srinivas
"bruce barker" wrote:
the popup extender must be declared in the row/col template, so instead
of a link column, put a link and the extender in the row/column template.

-- bruce (sqlwork.com)

srinivas wrote:
Hi All,
I'm having a grid view(GridView1) with a hyperlink column.It's ID is Link1
I want to show a popup on hyperlink click.
I'm using ajaxToolkit:ModalPopupExtender for that.
But when i'm using TargetControlID="Link1" for ajaxToolkit:ModalPopupExtender
I'm getting an error

System.InvalidOperationException: The TargetControlID of
'ModalPopupExtender1' is not valid. A control with ID 'Link1' could not be
found.

My ajaxToolkit syntax is

<ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender1" runat="server"
TargetControlID="GridView1"
PopupControlID="Panel1"
BackgroundCssClass="modalBackground"
DropShadow="true"
CancelControlID="CancelButton" />

Thanks in advance

Mar 6 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by davidjgonzalez | last post: by
1 post views Thread by William Youngman | last post: by
reply views Thread by Phillip Ian | last post: by
2 posts views Thread by Raymond Du | last post: by
3 posts views Thread by Jonathan Wood | last post: by
reply views Thread by rainxy | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.