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

Discussion in 'ASP .Net' started by =?Utf-8?B?V2ViTWF0cml4?=, Dec 8, 2004.

  1. 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.
    =?Utf-8?B?V2ViTWF0cml4?=, Dec 8, 2004
    #1
    1. Advertising

  2. =?Utf-8?B?V2ViTWF0cml4?=

    Lars Netzel Guest

    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" <> skrev i meddelandet
    news:...
    >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.
    >
    Lars Netzel, Dec 8, 2004
    #2
    1. Advertising

  3. Re: Best way to implement custom control: Repeater vs. Anything El

    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" <> skrev i meddelandet
    > news:...
    > >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.
    > >

    >
    >
    >
    =?Utf-8?B?V2ViTWF0cml4?=, Dec 8, 2004
    #3
  4. =?Utf-8?B?V2ViTWF0cml4?=

    Joe Fallon Guest

    Re: Best way to implement custom control: Repeater vs. Anything El

    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" <> wrote in message
    news:D...
    > 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" <> skrev i meddelandet
    >> news:...
    >> >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.
    >> >

    >>
    >>
    >>
    Joe Fallon, Dec 9, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. d[ - - ]b

    Multidimensional arrays? anything else?

    d[ - - ]b, May 18, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    1,672
    AlexS
    May 18, 2004
  2. Scott Allen
    Replies:
    0
    Views:
    609
    Scott Allen
    Feb 14, 2005
  3. Norman
    Replies:
    0
    Views:
    606
    Norman
    Feb 14, 2005
  4. LP
    Replies:
    14
    Views:
    945
  5. Markis Landis Gardner
    Replies:
    1
    Views:
    277
    Rudi Angela
    Feb 26, 2004
Loading...

Share This Page