Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Jul 07, 2012 02:04 AM by Decker Dong - MSFT
Jul 05, 2012 09:01 PM|LINK
I think I'm having a simple issue, but could use some help with how to fix it.
I'm creating a custom web control in my App_Code section (it's inheriting WebControl). In it, I have a Repeater object that is the basis of the control.
I've overriden the Render method with this:
protected override void Render(HtmlTextWriter writer)
/* SET SOME ATTRIBUTES FOR REPEATER */
The repeater always renders like no data is returned, but it should be returning one item.
I know it's not the settings of the repeater (I've created the repeater with the same settings on a page and it renders correctly). So now I'm wondering if it has to do with where I'm setting the attributes. I've tried setting them by overriding the OnInit
and OnDataBinding methods, but that didn't help either.
Could someone please help me?
Jul 05, 2012 09:15 PM|LINK
Have you put a break point there onRender to make sure something isn't causing it to fire more than once? Also can you confirm the writer property that is being sent to it has a value in that render method also. i'm just wondering if something isn't setting
the datasource properly. Or to late. Override the ondatabinding and put something like string s = string.Empty. Then put a breakpoint there just to confirm that it's even binding right and only once.
Coding is like life, learn from the past and work towards the future, trying to redo past code, ends in lost time and nothing new accomplished.
Jul 05, 2012 09:22 PM|LINK
Well the repeater is a custom control from our CMS. It allows us to specify text to display if Zero Rows are returned. The control consistantly displays that text, so I know the control is rendering. It's more that it's not rendering properly because it's
not getting the data from the database.
I've already emailed their support techs, but I was wondering if someone here had any ideas that might help.
Since this is the first time I've created a custom control this way, I figured I was not assigning the properties at the correct time.
Jul 05, 2012 09:30 PM|LINK
Usually to assing the datasource it's just like the regular control
so if your class
public class repeat : Web.UI.Controls.Repeater (thats a guess on where it's found)
is all you had done. then all you would need to do is assign it like you normally do.
It shouldn't require any crazy code as long as the base is the control
the only thing you need to be doing differently is override where it shows the repeater and show a label instead.
Jul 07, 2012 02:04 AM|LINK
The repeater always renders like no data is returned,
Have you save the Data contents in the ViewState or Session？You should know that without doing this，Html is of non-memorization……