473,608 Members | 2,667 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Best way to implement custom control: Repeater vs. Anything Else

I am struggling with implementing somewhat complicated UI web-control. I
explored Repeater, but I am not sure if it's the best way to go. I am leaning
towards writing my own custom control and creating elements on the fly
dynamically.
I have a control that needs to display 3 columns and n number of rows
depending on number of records. Sounds simple. But each Row has a control
with its own data source binding and value must be selected based on data.
Each row can be removed by the user or new row added. So far Repeater can do
all that, and I developed a prototype that does it.
But The problem is that I need adjust colspan=x for different. If there's no
previous data, I need to hide 1 column which has delete button and do colspan
= 2 on the last column. So user has to create a new record. I can't find an
easy way to do it, rather then writing custom code on ItemDataBound event or
ItemCreated and adding HTML text programmaticall y. But what's the point
having Repeater control? I might as well write my own implementation.

Nov 19 '05 #1
3 2844
I have basically done what you want to do in a datagrid..

In more complex Designsituation s just use ONE templateColumn and then add
yoru own basic HTML code in there.. you can also add another DataGrid within
a DataGrid Cell so you can do whatever you want really... Jsut add and
remove those datagrids or other ServerControls in EditCommand and
UpdateCommand events of the datagrid... You really don't need to create you
own control, the DataGrid in ASP.NET is extremely powerful with some
customizing.

Best Regards
/Lars
"WebMatrix" <We*******@disc ussions.microso ft.com> skrev i meddelandet
news:9B******** *************** ***********@mic rosoft.com...
I am struggling with implementing somewhat complicated UI web-control. I
explored Repeater, but I am not sure if it's the best way to go. I am
leaning
towards writing my own custom control and creating elements on the fly
dynamically.
I have a control that needs to display 3 columns and n number of rows
depending on number of records. Sounds simple. But each Row has a control
with its own data source binding and value must be selected based on data.
Each row can be removed by the user or new row added. So far Repeater can
do
all that, and I developed a prototype that does it.
But The problem is that I need adjust colspan=x for different. If there's
no
previous data, I need to hide 1 column which has delete button and do
colspan
= 2 on the last column. So user has to create a new record. I can't find
an
easy way to do it, rather then writing custom code on ItemDataBound event
or
ItemCreated and adding HTML text programmaticall y. But what's the point
having Repeater control? I might as well write my own implementation.

Nov 19 '05 #2
My delima is really amount of code/effort I have invest in this control. It
seems to me that to customize DataGrid or Repeater, I have to write the same
amount of code as I would if I developed my own control. See, data comes
from XML stream, so I already have code that parses this XML, so all I have
to do now is to place a few Controls.Add to XML parsing logic.
With DataGrid I still have to have XML parsing logic to convert it to a
DataSet or some collection of objects so it can databinded to .NET control.
And then write extra code in ItemDataBound event. Is it worth the effort?
"Lars Netzel" wrote:
I have basically done what you want to do in a datagrid..

In more complex Designsituation s just use ONE templateColumn and then add
yoru own basic HTML code in there.. you can also add another DataGrid within
a DataGrid Cell so you can do whatever you want really... Jsut add and
remove those datagrids or other ServerControls in EditCommand and
UpdateCommand events of the datagrid... You really don't need to create you
own control, the DataGrid in ASP.NET is extremely powerful with some
customizing.

Best Regards
/Lars
"WebMatrix" <We*******@disc ussions.microso ft.com> skrev i meddelandet
news:9B******** *************** ***********@mic rosoft.com...
I am struggling with implementing somewhat complicated UI web-control. I
explored Repeater, but I am not sure if it's the best way to go. I am
leaning
towards writing my own custom control and creating elements on the fly
dynamically.
I have a control that needs to display 3 columns and n number of rows
depending on number of records. Sounds simple. But each Row has a control
with its own data source binding and value must be selected based on data.
Each row can be removed by the user or new row added. So far Repeater can
do
all that, and I developed a prototype that does it.
But The problem is that I need adjust colspan=x for different. If there's
no
previous data, I need to hide 1 column which has delete button and do
colspan
= 2 on the last column. So user has to create a new record. I can't find
an
easy way to do it, rather then writing custom code on ItemDataBound event
or
ItemCreated and adding HTML text programmaticall y. But what's the point
having Repeater control? I might as well write my own implementation.


Nov 19 '05 #3
I jst finished building a page just like the one you describe!
I used a reapter and then nested a 2nd repeater inside the first one.
My biggest challenge was I need to do some work in ItemDataBound of the
nested repeater and it was not available in the code behind.

A little Google finally showed that all you do is add something like this
the <asp:repeater > tag:

<asp:repeater id=.... OnItemDataBound ="nestedRptr_It emDataBound" ...>

Then just add a Protected method named nestedRptr_Item DataBound (using the
same signture as a normal repeater and minus any Handles statement).

Then I was able to cast the sender to a Repeater and use e as a DataItem.

I seriously considered calculating the HTML on my own and skip the whole
exercise. And I would have done so had I not been able to figure out this
trick.

Good luck.
--
Joe Fallon

"WebMatrix" <We*******@disc ussions.microso ft.com> wrote in message
news:D1******** *************** ***********@mic rosoft.com...
My delima is really amount of code/effort I have invest in this control.
It
seems to me that to customize DataGrid or Repeater, I have to write the
same
amount of code as I would if I developed my own control. See, data comes
from XML stream, so I already have code that parses this XML, so all I
have
to do now is to place a few Controls.Add to XML parsing logic.
With DataGrid I still have to have XML parsing logic to convert it to a
DataSet or some collection of objects so it can databinded to .NET
control.
And then write extra code in ItemDataBound event. Is it worth the effort?
"Lars Netzel" wrote:
I have basically done what you want to do in a datagrid..

In more complex Designsituation s just use ONE templateColumn and then add
yoru own basic HTML code in there.. you can also add another DataGrid
within
a DataGrid Cell so you can do whatever you want really... Jsut add and
remove those datagrids or other ServerControls in EditCommand and
UpdateCommand events of the datagrid... You really don't need to create
you
own control, the DataGrid in ASP.NET is extremely powerful with some
customizing.

Best Regards
/Lars
"WebMatrix" <We*******@disc ussions.microso ft.com> skrev i meddelandet
news:9B******** *************** ***********@mic rosoft.com...
>I am struggling with implementing somewhat complicated UI web-control. I
> explored Repeater, but I am not sure if it's the best way to go. I am
> leaning
> towards writing my own custom control and creating elements on the fly
> dynamically.
> I have a control that needs to display 3 columns and n number of rows
> depending on number of records. Sounds simple. But each Row has a
> control
> with its own data source binding and value must be selected based on
> data.
> Each row can be removed by the user or new row added. So far Repeater
> can
> do
> all that, and I developed a prototype that does it.
> But The problem is that I need adjust colspan=x for different. If
> there's
> no
> previous data, I need to hide 1 column which has delete button and do
> colspan
> = 2 on the last column. So user has to create a new record. I can't
> find
> an
> easy way to do it, rather then writing custom code on ItemDataBound
> event
> or
> ItemCreated and adding HTML text programmaticall y. But what's the point
> having Repeater control? I might as well write my own implementation.
>


Nov 19 '05 #4

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

Similar topics

16
3013
by: D Witherspoon | last post by:
I am developing a Windows Forms application in VB.NET that will use .NET remoting to access the data tier classes. A very simple way I have come up with is by creating typed (.xsd) datasets. For example dsParts.xsd and including that in the data tier. I then will create a class that looks like this Public Class CPart Inherits dsParts
3
2728
by: anon | last post by:
I am having a hard time with makeing what I am trying to do work. I am making a questionaire web app. I have a custom control that has a label and 5 radio buttons. My problem is that each different topic for the questionaire is in a database and each questionaire will have a different number of questions. I am trying to use a repeater to creat multiple copies of the control, unfortunately when I do this the different controls act like...
0
1276
by: Joe | last post by:
I am having a hard time with setting a property on a custom server control that i am placing in a repeater. The control inherits from DropDownList. The property is being set in the repeater using the DataBinder.Eval method. I can write that value out to the screen, however, it is not available to the control. I think it is a problem with the databinding of the repeater making data available to the custom control too late. Below is a...
2
1898
by: John Holmes | last post by:
I am using radioButton controls in a data repeater and would like to incorporate the 'key' field into the 'id' attribute of the radioButton controls and name them something like: 'rad' + '<%# (string)DataBinder.Eval(Container.DataItem, "ParcelID") %>' + PropType1 I think part of the problem is that intially there is no data bound to this repeater section. The data doesn't get built until the user clicks a button on the form and then...
1
1230
by: JAPHET | last post by:
I have a web custom control consist of three text box i.e Employee number,First name, Last Name. I Created a web form with a Repeate control, I want to attach a Custom control to a repeater so as I can add a multiple rows at a time to my employee table. PLz help me how can i achieve this. Japhet.
4
2133
by: Rudy | last post by:
Hello all! I would like to take a row from a table and display this info in a nice layout. I tried the the reapeater, can't seemm to do too much with that. And I don't want a grid layout. I would like to lay out a bunch of lable controls, and have each value from each row(one at a time) bind in. I just wonder if this is a good way to approcah it, or is there a better way to custom layour your display data. It's my understanding you can...
5
3579
by: serge calderara | last post by:
Dear all, I am new in asp.net and prepare myself for exam I still have dificulties to understand the difference between server control and HTML control. Okey things whcih are clear are the fact that for server control component , code is running on the server side. But if I take as example a Label. I place on a webform an HTM label control and a WebForm label control, I could see that properties are different for
9
4680
by: Jaybuffet | last post by:
my aspx has something like this <asp:Repeater id="Repeater1" runat="server"> <ItemTemplate> <mycontrol:ctl id="ctlId" obj='<%# Container.DataItem %>' showItem="true"/> </ItemTemplate> /asp:Repeater> The DataSource for this Repeater is a CollectionBase of objects and is
8
3012
by: fernandezr | last post by:
I would like to use a user control as a template inside a repeater. Some of the fields in the control should be hidden depending on whether or not there is data. I'm still a ASP .Net newbie so the way I'm going about doing this might be a little off. I'd appreciate some help. Below is the code I have thus far but I'm not sure how to reference the user control within the foreach loop. <asp:Panel ID="pnlRosterProfile" runat="Server" />
0
7987
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8472
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8130
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6805
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5471
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3954
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4015
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2464
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1574
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.