472,353 Members | 1,026 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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 programmatically. But what's the point
having Repeater control? I might as well write my own implementation.

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

In more complex Designsituations 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*******@discussions.microsoft.com> skrev i meddelandet
news:9B**********************************@microsof t.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 programmatically. 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 Designsituations 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*******@discussions.microsoft.com> skrev i meddelandet
news:9B**********************************@microsof t.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 programmatically. 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_ItemDataBound" ...>

Then just add a Protected method named nestedRptr_ItemDataBound (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*******@discussions.microsoft.com> wrote in message
news:D1**********************************@microsof t.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 Designsituations 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*******@discussions.microsoft.com> skrev i meddelandet
news:9B**********************************@microsof t.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 programmatically. 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
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...
3
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...
0
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...
2
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...
1
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...
4
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...
5
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...
9
by: Jaybuffet | last post by:
my aspx has something like this <asp:Repeater id="Repeater1" runat="server"> <ItemTemplate> <mycontrol:ctl id="ctlId" obj='<%#...
8
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...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand....

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.