p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   ASP.NET 1.0 and 1.1 Professional (http://p2p.wrox.com/forumdisplay.php?f=57)
-   -   User COntrol Datagrid inside datagrid (http://p2p.wrox.com/showthread.php?t=23970)

rodmcleay January 17th, 2005 05:00 AM

User COntrol Datagrid inside datagrid
Hi All,
I am having some trouble with a datagrid that is a user control when using it inside a datagrid.
Basically as part of the edit template I have included a user control that is a databound control.
In the ItemDatabound event I set the user controls "ResourceID" (Public Field in user control), and it loads up fine.
Then I click on an image button to edit the User control datagrid record and this loads up fine also showing the edit template as it should.
When I go to save the changes, the user control seems to lose track of the "ResourceID" I have assigned to it and defaults back to zero.
The update to the database then assigns the wrong ResourceID.

Any Assistance would be appreciated.

They say, best men are molded out of faults,
And, for the most, become much more the better
For being a little bad.

rodmcleay January 17th, 2005 11:08 PM

I still don't know why this is happening but I have found an UGLY solution.

Basially I had to pass back both the recordID and the ResourceID mentioned below as a constucted Command Argument (3-6) of the user control Datagrid.
Then split the cammand argument to get the record ID to update the database and the Resource ID to reset the local varaible.

Still very strange as this is not required when not used within a datagrid.

They say, best men are molded out of faults,
And, for the most, become much more the better
For being a little bad.

tittlejoseph April 14th, 2007 07:38 AM

I've a similar problem. I've public field in usercontrol, i set it on aspx through databind. I use this control inside/outside datagrid, the only place when user control does not display any value is when I re-bind the grid on some button event of aspx. I tried to analyze the problem and found that Public field value is set at end whereas Oninit, onload are fired by then.

I can post complete help files, please help me resolving it. TittleJoseph@yahoo.com I'm getting mad [}:)]

 public string ProjectCode
        set { this.projectCode = value; }
        get { return this.projectCode; }
protected override void OnLoad(EventArgs e)
txtProjectCode.Text = projectCode;


<asp:datagrid ..>
             <HCL:ProjectDetail id="ProjectDetail3" runat="server"

a.aspx.csprivate void bindgrid()
        ArrayList AR = new ArrayList();
        DG.DataSource = AR;

    protected void re_bind_Click(object sender, EventArgs e)


planoie April 14th, 2007 10:11 AM

What about if you make the property directly access the textbox instead of the intermediate variable. Then you don't have to rely on a control load event (onInit) to set the textbox property.


All times are GMT -4. The time now is 09:46 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.