Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 17th, 2005, 05:00 AM
Friend of Wrox
Points: 2,376, Level: 20
Points: 2,376, Level: 20 Points: 2,376, Level: 20 Points: 2,376, Level: 20
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: , , Australia.
Posts: 596
Thanks: 1
Thanked 3 Times in 3 Posts
Default 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.
======================================
__________________
======================================
"They say, best men are molded out of faults,
And, for the most, become much more the better
For being a little bad."
--Shakespeare
======================================
 
Old January 17th, 2005, 11:08 PM
Friend of Wrox
Points: 2,376, Level: 20
Points: 2,376, Level: 20 Points: 2,376, Level: 20 Points: 2,376, Level: 20
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: , , Australia.
Posts: 596
Thanks: 1
Thanked 3 Times in 3 Posts
Default

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.
======================================
 
Old April 14th, 2007, 07:38 AM
Registered User
 
Join Date: Apr 2007
Location: Noida, , India.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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

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

a.aspx

<asp:datagrid ..>
 <ItemTemplate>
             <HCL:ProjectDetail id="ProjectDetail3" runat="server"
              ProjectCode='<%#Container.DataItem%>'
               />
..</asp:datagrid>

a.aspx.csprivate void bindgrid()
    {
        ArrayList AR = new ArrayList();
        AR.Add("C052532");
        AR.Add("C060879");
        DG.DataSource = AR;
        DG.DataBind();
    }

    protected void re_bind_Click(object sender, EventArgs e)
    {
        bindgrid();
    }

------
TittleJoseph@yahoo.com
 
Old April 14th, 2007, 10:11 AM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

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.

-Peter




Similar Threads
Thread Thread Starter Forum Replies Last Post
get value of textbox inside datagrid khaink ASP.NET 1.0 and 1.1 Basics 9 October 2nd, 2007 10:05 AM
DropDownList Inside a datagrid @shish ASP.NET 1.0 and 1.1 Professional 3 January 29th, 2007 07:24 PM
User Control for datagrid paging mike_remember ASP.NET 1.0 and 1.1 Professional 0 December 29th, 2005 08:59 AM
user control within datagrid lily611 General .NET 1 March 30th, 2005 07:53 PM
Datagrid in a User control Vishal_7 ASP.NET 1.0 and 1.1 Professional 0 January 25th, 2005 11:29 AM





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