473,434 Members | 1,381 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,434 software developers and data experts.

Include a usercontrol in a table

Hi,

This question is related with c# and ASP.NET, (I could't find the rigth
forum).

What I need to do is to add a usercontrol in a row of my table using the
server code (I know how to do it on the front-end). The idea is to show the
search results on the page, every entry is a usercontrol (obviously the same
loaded with different data). I have tried this but it does not work, any
ideas? (here is an example)

protected MyUserControl[] m_MyControls;
protected Table m_MyTable;
public void On_Load(...)
{
MyControls = new MyUserControl[2];
MyControls[0] = new MyUserControl();
MyControls[1] = new MyUserControl();

MyControl[0].Description = "Text1";
MyControl[1].Description = "Text2";

MyTable.Rows[0].Cells[0].Controls.Add(MyControl[0]);
MyTable.Rows[0].Cells[0].Controls.Add(MyControl[1]);
}

No errors are triggered, seems to be adding the controls but no ouput is
visible (none even using "View source").

Any Ideas?
Thanks


--
Salvador Alvarez Patuel
Exony Ltd - London, UK
Nov 17 '05 #1
2 1586
Hi,

"Salvador" <Sa******@discussions.microsoft.com> wrote in message
news:3A**********************************@microsof t.com...
Hi,

This question is related with c# and ASP.NET, (I could't find the rigth
forum).
microsoft.public.dotnet.framework.aspnet will do
What I need to do is to add a usercontrol in a row of my table using the
server code (I know how to do it on the front-end). The idea is to show
the
search results on the page, every entry is a usercontrol (obviously the
same
loaded with different data). I have tried this but it does not work, any
ideas? (here is an example)


You can't do it like that, first of all what is wrong with doing it in the
aspx page? ( I assume you refer to this when you talk about the front-end) ?
I always do it like that, you have all the grid declaration in the aspx
page

In case you dont want to do it for some reason the solution is intercept the
DataGrid.ItemDataBound event. it does fire when the grid is binding the
datasource.
cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

Nov 17 '05 #2
Hi,

Thanks for the reply,
the problem that I have is that my user control is the entity, I don't know
how many I have to render until the page is processed (sorry, is my first
project in aspnet)

So, if I have it on the aspx page I will have (generic code)

<table>
<row>
<cell>
<MyHeader:MyUserControl Id = "MyName" runat ="server"/>
</cell>
</row>
</table>

This works great for a single instance but I want several, the result on
html has to be something like this:

<cell>
<MyHeader:MyUserControl Id = "MyName" runat ="server"/>
<MyHeader:MyUserControl Id = "MyNamex" runat ="server"/>
<MyHeader:MyUserControl Id = "MyNamexx" runat ="server"/>
<MyHeader:MyUserControl Id = "MyNamexxx" runat ="server"/>
</cell>

The amount of them is dynamic, that's why I am creating several instances of
the user control on the server code. To do an analogy, is like creating a
data repeater where the individual content is a usercontrol.

Hope this makes sense :)

Salva


--
Salvador Alvarez Patuel
Exony Ltd - London, UK
"Ignacio Machin ( .NET/ C# MVP )" wrote:
Hi,

"Salvador" <Sa******@discussions.microsoft.com> wrote in message
news:3A**********************************@microsof t.com...
Hi,

This question is related with c# and ASP.NET, (I could't find the rigth
forum).


microsoft.public.dotnet.framework.aspnet will do
What I need to do is to add a usercontrol in a row of my table using the
server code (I know how to do it on the front-end). The idea is to show
the
search results on the page, every entry is a usercontrol (obviously the
same
loaded with different data). I have tried this but it does not work, any
ideas? (here is an example)


You can't do it like that, first of all what is wrong with doing it in the
aspx page? ( I assume you refer to this when you talk about the front-end) ?
I always do it like that, you have all the grid declaration in the aspx
page

In case you dont want to do it for some reason the solution is intercept the
DataGrid.ItemDataBound event. it does fire when the grid is binding the
datasource.
cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Pete | last post by:
I am building an ASP.NET application and have just encountered something very strange which I would like explained if possible. In BaseForm.ascx I have the following <form> element: <form...
2
by: bill yeager | last post by:
When trying to run my web project, I get the following error: Parser Error Description: An error occurred during the parsing of a resource required to service this request. Please review the...
1
by: al | last post by:
Greetings, I included a UserControl (UC)on webpage. It works fine except when I change document direction to 'rtl', UC doesn't resize with the rest of document. It just disappears behinde rest...
0
by: Diego | last post by:
Hallo! I have an HtmlTable with a UserControl into it. Setting table.Visible = false all controls in table have .Visible = false. Then, setting table.Visible = true all controls in table except...
12
by: Joe | last post by:
Hello All: Do I have to use the LoadControl method of the Page to load a UserControl? I have a class which contains three methods (one public and two private). The class acts as a control...
3
by: Larry | last post by:
Hi, I need a method to dynamically include a server side include in my asp.net page. The problem is, the include file contains asp.net controls, and I can't find a way to get the controls to...
0
by: Arpan | last post by:
I have created the following UserControl (the file is named LoginForm.ascx): <script language=VB runat="server"> Public UName As String Public UPwd As String Public BColor As String Public...
6
by: MeowCow | last post by:
I have created a UserControl that encapsulates a third party data grid. My goal was to create my own DataSource and DataMember properties that forward the binding to the third party grid, then use...
2
by: Academia | last post by:
I want to include a button that opens a .chm help file on a usercontrol. I haven't yet looked at how the button is to open the help but before I go there I need to know how to include the .chm...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.