By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,474 Members | 3,141 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,474 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.