Hi y'all


I need to create a user control on a web page and I have no idea whatsoever of how to go about it.
The control should consist of a 3 by 3 grid, with each grid cell having its own color, and also the capability of displaying a value passed to it from an array.
I am using VB.NET 2003.
Thanks


Stanley

create your user control using the vs.net designer, then create an html table having 3 by 3 cells, give them the colors appropriately. create a public property in the user control for the array list as follows :

your usercontrol code behind :

public class myUserControl 
{
private ArrayList _myArrayList;
public ArrayList myArrayList
{
get
{
return _myArrayList;
}
set
{
_myArrayList = value;
}
}

}

register the usercontrol to the code behind so that you can reach the public properties
myUserControl myUserControlIDonthepage;
when you add the usercontrol to the page, you can fill the array list in the page load event of the page as follows :

void Page_Load(object sender, EventArgs e)
{
myUserControlIDonthepage.myArrayList.Add(myValue);
}

then you can display the items in the arraylist in the html table in usercontrol as follows :

<table>
<tr><td><%=myArrayList[0].ToString()%></td></tr>
</table>

you do that 9 times till you fill all the table with appropriate values

If you need it databound instead of array, you can also put it into a repeater control (the entire table in the itemtemplate block) and bind values to it via page_load. If you need assistance let us know.

Thanks

tried out Serkansendur's and it has so far worked, So I am going to try out the second option.

This article has been dead for over six months. Start a new discussion instead.