CodeVerge.Net Beta


   Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums




Can Reply:  No Members Can Edit: No Online: Yes
Zone: > Asp.Net Forum > general_asp.net.web_parts_and_personalization Tags:
Item Type: Date Entered: 3/28/2006 2:07:35 AM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
NR
XPoints: N/A Replies: 2 Views: 196 Favorited: 0 Favorite
3 Items, 1 Pages 1 |< << Go >> >|
"lchrennew" <>
NewsGroup User
How to use WebPartZone control in gridview control's template?3/28/2006 2:07:35 AM

0

I Need Your Help To Solve The Following Problem.Thanks.

I want to use WebPartZone control (NOT ATLAS) like this:

        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False">
            <Columns>
                <asp:TemplateField HeaderText="templatecol">
                    <ItemTemplate>
                        <asp:WebPartZone ID="WebPartZone1" runat="server">
                            <ZoneTemplate>
                                <asp:Button ID="Button1" runat="server" Text="Button" />
                            </ZoneTemplate>
                        </asp:WebPartZone>
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
        </asp:GridView>


In my project, I bind data for the gridview in Page_Init(), the error is:

Server Error in '/' Application.

A Web Part or Child Control of a Generic Web Part has already been added with ID 'gwpgridviewForums'.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: A Web Part or Child Control of a Generic Web Part has already been added with ID 'gwpgridviewForums'.

Source Error:

Line 49:         sda.Fill(dt);
Line 50:         gridviewGroups.DataSource = dt;
Line 51:         gridviewGroups.DataBind();
Line 52:         con.Close();
Line 53:     }

Source File: d:\Project\RenSystem\Forum\Default.aspx.cs    Line: 51

Stack Trace:

[InvalidOperationException: A Web Part or Child Control of a Generic Web Part has already been added with ID 'gwpgridviewForums'.]
   System.Web.UI.WebControls.WebParts.WebPartManagerControlCollection.AddWebPartHelper(WebPart webPart) +817566
   System.Web.UI.WebControls.WebParts.WebPartManagerControlCollection.AddWebPartsFromZone(WebPartZoneBase zone, WebPartCollection webParts) +698
   System.Web.UI.WebControls.WebParts.WebPartManager.RegisterZone(WebZone zone) +343
   System.Web.UI.WebControls.WebParts.WebZone.OnInit(EventArgs e) +92
   System.Web.UI.WebControls.WebParts.WebPartZone.OnInit(EventArgs e) +9
   System.Web.UI.Control.InitRecursive(Control namingContainer) +321
   System.Web.UI.Control.InitRecursive(Control namingContainer) +198
   System.Web.UI.Control.InitRecursive(Control namingContainer) +198
   System.Web.UI.Control.InitRecursive(Control namingContainer) +198
   System.Web.UI.Control.AddedControl(Control control, Int32 index) +2065295
   System.Web.UI.ControlCollection.Add(Control child) +146
   System.Web.UI.WebControls.RowControlCollection.Add(Control child) +34
   System.Web.UI.ControlCollection.AddAt(Int32 index, Control child) +25
   System.Web.UI.WebControls.RowControlCollection.AddAt(Int32 index, Control child) +40
   System.Web.UI.WebControls.GridView.CreateRow(Int32 rowIndex, Int32 dataSourceIndex, DataControlRowType rowType, DataControlRowState rowState, Boolean dataBind, Object dataItem, DataControlField[] fields, TableRowCollection rows, PagedDataSource pagedDataSource) +161
   System.Web.UI.WebControls.GridView.CreateChildControls(IEnumerable dataSource, Boolean dataBinding) +3004
   System.Web.UI.WebControls.CompositeDataBoundControl.PerformDataBinding(IEnumerable data) +59
   System.Web.UI.WebControls.GridView.PerformDataBinding(IEnumerable data) +11
   System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable data) +111
   System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +29
   System.Web.UI.WebControls.DataBoundControl.PerformSelect() +149
   System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +70
   System.Web.UI.WebControls.GridView.DataBind() +4
   Forum_Default.Page_Init() in d:\Project\RenSystem\Forum\Default.aspx.cs:51
   System.Web.Util.CalliHelper.ArglessFunctionCaller(IntPtr fp, Object o) +5
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +781871
   System.Web.UI.Control.OnInit(EventArgs e) +2069660
   System.Web.UI.Page.OnInit(EventArgs e) +9
   System.Web.UI.Control.InitRecursive(Control namingContainer) +321
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +692


Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.42

 

I Need Your Help To Solve this Problem.Thanks.

"mharder" <>
NewsGroup User
Re: How to use WebPartZone control in gridview control's template?3/28/2006 6:27:53 PM

0

The error message says the ID is "gwpgridviewForums", but your example uses the ID "Button1".  I'm assuming the page that caused the error has a WebPart with ID "gridviewForums".

Each WebPart on the page needs to have a unique ID.  If you have a WebPart inside a GridView ItemTemplate, then all instances of this WebPart will have the same ID, which is an error.  You need to ensure that all WebPart have unique IDs.

-Mike

http://blogs.msdn.com/mharder

This posting is provided "AS IS" with no warranties, and confers no rights.
"lchrennew" <>
NewsGroup User
Re: How to use WebPartZone control in gridview control's template?3/29/2006 12:25:09 AM

0

mharder:
The error message says the ID is "gwpgridviewForums", but your example uses the ID "Button1".  I'm assuming the page that caused the error has a WebPart with ID "gridviewForums".

Each WebPart on the page needs to have a unique ID.  If you have a WebPart inside a GridView ItemTemplate, then all instances of this WebPart will have the same ID, which is an error.  You need to ensure that all WebPart have unique IDs.

-Mike

Yes, in my project, there is a WebPartZone control which contains a gridview control named "gridviewForums" inside a GridView Item Template.

Of cource, I want all WebPart have unique IDs, but I cannot bind data to the webpart's ID prop like this: <ItemTemplate><asp:WebPartZone><asp:Label ID='<%# Eval("rowId") %>'></asp:Label></asp:WebPartZone></ItemTemplate>, I was told that the Label ID need SIMPLE VALUE . How to solve this problem? Thanks, expecting your reply, sir.

3 Items, 1 Pages 1 |< << Go >> >|


Free Download:













how to display the title from the sitemapnode?

change theme for masterpage!

javascript error

can i have more than one .sitemap in my application?

not reading my textbox

blank target link

default.skin does not seem to be being referenced properly

finding controls on parent page from child page

pdf file in contentplaceholder

treeview not refreshing on autopostback

random erros when accesing masterpage's body tag

menu in masterpage

javascript problem in masterpage

how do you change the path for to a .dll?

question about roles attribute

treenodecheckchanged does not work!!

overriding html header attributes-keywords and descriptions for content pages

embedd media player in content placeholder

sharing themes cross application

resolution problem

i cannot create master page after installing .net 2.0

asp.net 2.0 menu control

fixed asp.net menu in a page

error pop up not working on master page ".vb"

can an <asp:contentplaceholder> be variable?

change masterpagefile in master page code

wizard control - validation control!

masterpage issue

how to add buttons to tree view node

image on master page not visible

menu/treeview hybrid site navigation?

how to get background image to display on all pages

is it possible to pick controls from other pages or show multiple contentpages simultaneously?

how to enable item wrapping on asp:menu?

open a treeview at the right place

dynamic url in sitemap?

javascript not executing when i include a masterpage

page life cycle and master pages

nested master pages

dynamicmenustyle backcolor issue

master page hell

vertical sub menu items…

gridview not sorting when used in masterpage

menu control disable hover

how to create a "loading" page content page

can you overlay a menu on top of an image?

defaultbutton property with master page

how do i create an asp.net website template for new sites that use my masterpage?

menu

problem when implementing url rewriting

   
  Privacy | Contact Us
All Times Are GMT