Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > ASP Forms
|
ASP Forms As of Oct 5, 2005, this forum is now locked. Please use "Classic ASP beginner" at http://p2p.wrox.com/forum.asp?FORUM_ID=54 or "Classic ASP Professional" http://p2p.wrox.com/forum.asp?FORUM_ID=56 instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP Forms 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 August 17th, 2004, 11:12 AM
Authorized User
 
Join Date: Jul 2004
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to change the properties of a WebUserControl

I build a WebUserControl (.ascx file) which contains many properties.Each properties has a default value.This control will show the data as a bitmap of a meter or traffic lamp. I test it in an .aspx file.
It work well.Then I build a final .aspx file which link to a SqlServer database ,pull the data from three table into a dataset.
then I put a datalist control into this form with the
<ItemTemplate>
<uc1:myControl id=myCtl runat=server />
</ItemTemplate>
My problem is for each row in the dataset.How can I tied the data in one column to the corresponding propertie in my control? I put my code in the .cs file.
the code like these can cause the error:
myCtl.property1=ds.Tables[0].rows[i]["Column1Name"] ;
To set the property in html page like these also cause error:
<uc1:myControl id=myCtl runat=server
property1=<%#Container.DataItem("Column1Name")%>
/>
             How should I do next ?
                     doctorsom


 
Old August 17th, 2004, 11:40 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

If you use the ItemCreated or ItemDataBound event, you can access each row, which you can provide the properties in the row. The following code would be in one of these events:

[code]
private sub datagrid1_ItemCreated(..)
  'Get the data somehow
  MyControl myCtl = (MyControl)e.Item.Cells(<index>).FindControl("myCt l");
  myCtl.property1 = ds.tables[0].rows[i].item["Column1Name"];
end sub





Similar Threads
Thread Thread Starter Forum Replies Last Post
Change An Objects Properties Via Sub Routine Rood67 Access 6 October 12th, 2007 12:14 PM
function - change forms txtbox properties feets Access VBA 3 May 11th, 2007 10:05 AM
TSQL to change SQL Server Agent Properties happygv SQL Server 2000 1 May 2nd, 2007 01:56 PM
Change the properties of a textbox control? marksartwork ASP.NET 1.0 and 1.1 Basics 7 April 4th, 2006 04:55 PM
Change style attribute of a WebUserControl YiannisF ASP.NET 1.0 and 1.1 Basics 1 July 10th, 2004 02:19 PM





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