Wrox Programmer Forums
|
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 July 4th, 2005, 03:23 AM
Authorized User
 
Join Date: Jun 2005
Posts: 97
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to aldwinenriquez
Default Problem with validation inside user control

I have a user control called ucIntControl inside a datagrid that will accept integer inputs.I added a Rangevalidator control inside the usercontrol and set the minvalue and maxvalue to be both equal to 0.

I want to modify the RangeValidator.MinValue and MaxValue in the OnItemDatabound eventhandler by using usercontrol properties but its not working.Here's my code:

Inside the UserControl:
public int Minimum
{
  get{
   return int.Parse(v_Range.MinimumValue);
     }
  set{
     v_Range.MinimumValue = value.ToString();
     }
}

public int Maximum
{
  get{
     return int.Parse(v_Range.MaximumValue);
      }
  set{
     v_Range.MaximumValue = value.ToString();
     }
}

Inside the page that contains the datagrid:

//set the min and max from fields 1(min) and 2(max) in the datasource
ucIntControl intItem = (ucIntControl)e.Item.Cells[0].Controls[4];
intItem.Minimum = int.Parse(dt.Rows[e.Item.DataSetIndex][1].ToString());
intItem.Maximum = int.Parse(dt.Rows[e.Item.DataSetIndex][2].ToString());

Everytime the page is loaded,RangeValidator always use the 0 to 0 range not the one from fields in the datasource.

Any solution?



Aldwin Enriquez
"Dont you ever give up!"
__________________
\"Dont you ever give up!\"
 
Old July 4th, 2005, 04:44 AM
Authorized User
 
Join Date: Jun 2005
Posts: 97
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to aldwinenriquez
Default

don't bother,i had it working now..Thanks.

Aldwin Enriquez
"Dont you ever give up!"
 
Old April 14th, 2007, 07:05 AM
Registered User
 
Join Date: Apr 2007
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. [email protected] 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();
    }

------
[email protected]
 
Old July 1st, 2007, 09:53 AM
Registered User
 
Join Date: Apr 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I solved it the following way
ProjectDetail.ascx.cs
private bool updated = false;
 public string ProjectCode
    {
        set { this.projectCode = value;
if ( !updated )
{
update();
updated = true;
}
}
        get { return this.projectCode; }
    }
protected override void OnLoad(EventArgs e)
{
 updated = true;
 update();
}
private void update()
{
txtProjectCode.Text = projectCode;
}

------
[email protected]





Similar Threads
Thread Thread Starter Forum Replies Last Post
Pop up window from inside Web user control debjanib ASP.NET 2.0 Basics 5 October 22nd, 2008 12:37 AM
Validation Control Problem manojbhoyar ASP.NET 1.0 and 1.1 Basics 4 June 20th, 2008 04:05 AM
User COntrol Datagrid inside datagrid rodmcleay ASP.NET 1.0 and 1.1 Professional 3 April 14th, 2007 10:11 AM
Much much problem with the User Control! daffodils ASP.NET 1.0 and 1.1 Basics 7 October 20th, 2006 10:46 AM





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